Skip to content

HydreIO/lru_set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lru_set

Basic no-deps Lru Set implementation with timeout support

Add elements in the set and the last used will drop out of it when full. Elements will also expire and be removed if max_age is specified

📦 Install

npm i @hydre/lru_set

Usage

import Lru from 'lru_set'

const cache = Lru({
  capacity: 5,
  max_age: 100, // if specified, ms before removing an element
  on_eviction: element => { }
})

cache.add(1)
cache.access(5) // returns weither or not an element is still present and also reset his age

About

A basic lru set implementation

Resources

Stars

Watchers

Forks

Packages

No packages published