mst-persist icon indicating copy to clipboard operation
mst-persist copied to clipboard

add expiration time?

Open sabermazoji opened this issue 5 years ago • 2 comments

it is possible to add an expire time for local storage?

sabermazoji avatar Oct 24 '20 16:10 sabermazoji

@sabermazoji so localStorage has no expiration built-in.

If you'd like to expire entries in your app, you'd have to add an expiration field or something to your models and just throw away any objects that are dated. There's a guide on doing this with localStorage directly, but the same concept could apply here.

Once I finally merge Transforms (#16) (which is unfortunately still blocked by multi-entry support upstream...), one could make a custom transform that encapsulates those details away from your app though

agilgur5 avatar Oct 25 '20 01:10 agilgur5

For anyone else finding this, there are also other storage engines that support expiration out-of-the-box, such as localstorage-slim, localforage-cache, and likely many others (found those from a very quick search).

A Transform could still abstract this kind of functionality to a higher level in order to apply to many different storage engines. Different options with different trade-offs to them

agilgur5 avatar Jul 19 '23 07:07 agilgur5