Feature: TTL or Auto-expiration
Closed this issue · 2 comments
I have some boilerplate code I have to use around my store access to refresh the data after a period of time. Thought it would be nice if it was implemented at a library level. addStore()
could accept a ttl
parameter, which would be a duration. On put
's, an expiration time can be generated and on get
's, the expiration time can be checked. If the data has expired it can call a 'generator' function (a callback) to regenerate the data. This is basically what I do now to refresh the cache every day.
Hi @beeftornado!
It's a nice idea for plugin (treo-ttl
). You can check example for more information: https://github.com/alekseykulikov/treo/blob/master/examples/find-in-plugin.js
I've added support for store.opts, which you can use in your custom put/get methods, but it's not released yet, because it contains some improvements around transaction management and better schema support, which has not worked in websql yet.
Let me know if I can you more to figure out this feature.
I hope someone will create a plugin for this idea eventually, close for now