1.0.0 • Published 7 years ago

modest-lru v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

About

Simple little LRU cache that works in node & browser. Based on the hashlru algorithm. Uses Maps under the hood.

Install

$ npm install modest-lru
# OR
$ yarn add modest-lru

Usage

const ModestLRU = require('modest-lru')
const lru = new ModestLRU(50) // Max size of 50

const foo = 'foo'
const baz = function baz() {}

lru.set(foo, 5)
lru.set(baz, 60)
lru.get(foo) // 5
lru.get(baz) // 60
lru.has(baz) // true
lru.has(6) // false
lru.remove(baz) // Remove key baz from cache 
lru.clear() // Clear the cache

Contributing

Contributions are welcome!

  1. Fork it.
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Or open up a issue.

License

Licensed under the MIT License.