Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

dcousens/sru.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sru

build status Version

A dead simple, in memory, somewhat-recently-used cache.

O(1) insertion, retrieval and deletion.

ESNext alternative

If you can, don't use this library. Use an ESNext WeakMap instead.

Examples

function cubed (x) {
  return x * x * x
}

let sru = require('sru')
let cache = sru(100)

console.log(cache(8, cubed), 512)
console.log(cache(8, cubed), 512) // cubed was not called this time

License MIT

About

A dead simple, performant somewhat-recently-used cache, busts after N insertions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published