Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/e0ipso/keyv-lru
An in-memory LRU back-end for Keyv.
https://github.com/e0ipso/keyv-lru
Last synced: 2 months ago
JSON representation
An in-memory LRU back-end for Keyv.
- Host: GitHub
- URL: https://github.com/e0ipso/keyv-lru
- Owner: e0ipso
- Created: 2018-06-15T14:43:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T13:35:05.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T02:26:34.899Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.08 MB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Keyv - LRU
This project is part of the Keyv suite.
Installation
In order to use LRU as your store in Keyv you will need to:
Install
Install this module in your project:
npm install keyv-lru
Features
This module is based on the tiny-lru
module. This is one of the best performing libraries for LRU storages.
Usage
Create your Keyv object by executing:
```js
const { KeyvLru, KeyvLruManagedTtl } = require('keyv-lru');
const options = {
max: 1000,
notify: false,
ttl: 0,
expire: 0,
};
const keyvLru = new KeyvLru(options);
const keyvLruManagedTtl = new KeyvLruManagedTtl(options);
```
See tiny-lru
to learn about the
available options.
Managed TTLs
KeyvLruManagedTtl uses a managed TTL strategy instead of timers. This is useful
for serverless architectures. tiny-lru expires entries based on timers, that
means that the event loop is not empty when the lambda function is finished.
That blocks the end of the execution.
This implementation will store the expiration time along with the cached data
and it will deleter expired items upon retrieval. Alternatively there is an
evictExpired()
method that will evict all the expired items.
Even when not using tiny-lru
‘s built-in expiration system based on timers, we
still benefit a lot from the LRU store.
Contributors
Contributors
Mateu Aguiló Bosch
License
keyv-lru is MIT licensed.