Using sqlite adapter with LRU
Rinse12 opened this issue · 1 comments
Hey, thanks for open sourcing this library.
We're interested in using this library to store data that would be accessed over a long period of the time in sqlite, but we don't want the data to grow too big. Ideally something like, new Keyv(
sqlite://${dbPath}, {namespace: "cache-items", size: 1000})
would evict least accessed items automatically. Is this possible with the current release?
Hello, it seems you want to use keyv as LRU. You can bring your own store adapter on top of sqlite to take control over the size, similar to quick-lru example:
https://keyvhq.js.org/#/?id=storage-adapters
What is quick-lru doing is to wrap set/get methods to control when to evict:
https://github.com/sindresorhus/quick-lru/blob/main/index.js#L69