[Feature request] Conditionally use `maxAge`
Closed this issue · 1 comments
ehmicky commented
I would like to use maxAge
depending on a condition. For example: do not use maxAge
when network is temporarily offline, use it otherwise.
Note that this condition:
- is not constant, i.e. I cannot set it when
moize
is initialized. For example, maybe when I calledmoize()
the network was not offline yet, but one hour later it is now offline. - does not depend on the cache key, so
onExpire()
cannot be used.
Possible solutions:
- allow
maxAge
to be a function returning anumber
(includingInfinity
) - add a
useMaxAge(functionArgs) => boolean
, or similar - anything else you might think of :)
Thanks for this great library!
ehmicky commented
It turns out don't need this feature in my code because I don't actually need offline support. I am closing this issue.