@digitalcredentials/lru-memoize

2.1.4 • Public • Published

LRU-Memoize (@digitalcredentials/lru-memoize)

Node.js CI NPM Version

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 with maxAge, 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.

Readme

Keywords

Package Sidebar

Install

npm i @digitalcredentials/lru-memoize

Weekly Downloads

301

Version

2.1.4

License

BSD-3-Clause

Unpacked Size

11.8 kB

Total Files

12

Last publish

Collaborators

  • kezike
  • klemoie
  • codenamedmitri
  • kimhd
  • uligall
  • alexander.muehle
  • stuartf
  • jchartrand
  • kiliankae