最近React Queryがv4になりました。 オプションのcacheTime, staleTimeについて何回ググっても忘れてしまうため、 例え話で理解してみようと思います。 公式ドキュメント cacheTime The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different cache times are specified, the longest one will be used. 未使用/非活動状態のキャッシュデータがメモリ内に残る時間(ミリ秒
![【React Query】情報屋の例えでcacheTime, staleTimeを理解する](https://cdn-ak-scissors.b.st-hatena.com/image/square/005dd2ef01f278f0233de3693b0f76187290c0c8/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fzenn%2Fimage%2Fupload%2Fs--nSdzi6sw--%2Fc_fit%252Cg_north_west%252Cl_text%3Anotosansjp-medium.otf_55%3A%2525E3%252580%252590React%252520Query%2525E3%252580%252591%2525E6%252583%252585%2525E5%2525A0%2525B1%2525E5%2525B1%25258B%2525E3%252581%2525AE%2525E4%2525BE%25258B%2525E3%252581%252588%2525E3%252581%2525A7cacheTime%25252C%252520staleTime%2525E3%252582%252592%2525E7%252590%252586%2525E8%2525A7%2525A3%2525E3%252581%252599%2525E3%252582%25258B%252Cw_1010%252Cx_90%252Cy_100%2Fg_south_west%252Cl_text%3Anotosansjp-medium.otf_37%3Atokutsu%252Cx_203%252Cy_121%2Fg_south_west%252Ch_90%252Cl_fetch%3AaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL3plbm4tdXNlci11cGxvYWQvYXZhdGFyL2U3Zjg0MTY0NTguanBlZw%3D%3D%252Cr_max%252Cw_90%252Cx_87%252Cy_95%2Fv1627283836%2Fdefault%2Fog-base-w1200-v2.png)