Description
context
Almost everyone gets cacheTime
wrong (exhibit A). It sounds like "the amount of time that data is cached for", but that is not correct.
cacheTime
does nothing as long as a query is still in used. It only kicks in as soon as the query becomes unused. After the time has passed, data will be "garbage collected" to avoid the cache from growing (see also this explanation).
RTK Query has the same feature - their prop is called keepUnusedDataFor. I think this is quite descriptive but also a bit long.
proposal
- rename
cacheTime
togcTime
gc
is referring to "garbage collect" time. It's a bit more technical, but also a quite well known abbreviation in computer science.
Also, it is not something that most people will have to customize. The default of 5 minutes is usually fine. A rename will reduce the chance that this property is mixed up with staleTime
.
Lastly, if someone doesn't immediately know what gcTime
stands for, they will (hopefully) consult the docs. This is a lot better than thinking they know what cacheTime
does.
Here is an old discussion on that topic: