kb-node-lru
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

kb-node-lru

Simple JS LRU Cache, v3.0.0+ now written in TypeScript.

npm install kb-node-lru
import LRU from 'kb-node-lru'

const cache1 = new LRU({maxAgeMs: 10000, maxStorage: 100})
const cache2 = new LRU({
  maxAgeMs: 10000,
  maxStorage: 100,
  sizeFn: o => {
    o.kilobytes_or_whatever()
  },
})
const cache3 = new LRU({maxAgeMs: Infinity, maxStorage: Infinity})

cache2.put('foo', someObject)
cache2.get('foo') // someObject
cache2.has('foo') // true
cache2.remove('foo') // removes it
cache2.toArray() // an array of objects with keys and access times
cache2.logMe() // returns big string for debugging

Contributing

  • run yarn modules to install necessary dev modules
  • run yarn dev --watch to watch typescript and compile while working
  • run yarn test to make sure it passes all tests
  • run yarn memtest to watch how much memory it uses with repeated large LRU creation/removals

Readme

Keywords

Package Sidebar

Install

npm i kb-node-lru

Weekly Downloads

0

Version

3.0.0

License

ISC

Unpacked Size

25.9 kB

Total Files

9

Last publish

Collaborators

  • malgorithms