@digitalcredentials/lru-memoize
v2.1.4
Published
LRU Memoize
Downloads
1,009
Readme
LRU-Memoize (@digitalcredentials/lru-memoize)
A Memoized wrapper around the javascript
lru-cache
library.
Table of Contents
Background
(Forked from digitalbazaar/lru-memoize
v2.0.0
to provide TypeScript and ReactNative compatibility.)
lru-memoize is used to
to memoize promises
(as opposed to just the results of the operations),
which helps in high-concurrency use cases. (And in turn, it uses
lru-cache
under the hood.)
The memoized LruCache
constructor passes any options given to it through to
the lru-cache
constructor, so see that repo for the full list of cache
management options. Commonly used ones include:
max
(default: 100) - maximum size of the cache.maxAge
(default: 5 sec/5000 ms) - maximum age of an item in ms.updateAgeOnGet
(default:false
) - When using time-expiring entries withmaxAge
, setting this to true will make each entry's effective time update to the current time whenever it is retrieved from cache, thereby extending the expiration date of the entry.
Install
To install locally (for development):
git clone https://github.com/digitalcredentials/lru-memoize.git
cd lru-memoize
npm install
Contribute
PRs accepted.
If editing the Readme, please conform to the standard-readme specification.
License
- MIT License - DCC - TypeScript compatibility.
- New BSD License (3-clause) © 2020-2021 Digital Bazaar - Initial implementation.