Skip to content
/ lru-js Public

Leat Recently Used cache implementation in JS

License

Notifications You must be signed in to change notification settings

drokeye/lru-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lru-js

Simple Least Recently Used cache algorithm implementation in Javascript.

Installation

Make sure you have git installed.

> git clone https://github.com/XiehCanCode/lru-js

then import it as a local package!

Example

const LRUCache = require('lru-js/index');

let cache = LRUCache(2) // limit is optional, default to 120
cache.insert(1, 2)
cache.insert(2, 3)
cache.get(1) // here this key-value would be pushed to the end
cache.insert(3, 4) // this would insert the new key-value pair at the end and evicts the least used key-value pair since we're exceeding the limit, in this case it's {2 => 3}
console.log(cache) // LRUCache {limit: 2, map: Map(2) { 1 => 2, 3 => 4 }}

Contributing

First of all thanks for thinking about contributing to this crap and yea feel free to contribute!

Please run test and make sure your code passes all the test:

> npm install mocha -g
> npm test

License

MIT

About

Leat Recently Used cache implementation in JS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published