Skip to content

Key-value least-recently-used (LRU) cache module written in Typescript with zero dependencies.

Notifications You must be signed in to change notification settings

CyrusKao/kv-lru-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KV LRU Cache

Key-value least-recently-used (LRU) cache module written in Typescript with zero dependencies.

See how it's implemented at my blog post.

Installation

npm i kv-lru-cache

Usage

import Cache from 'kv-lru-cache';

const cache = new Cache<string, number>(2, 3);

cache.set('a', 1);
cache.set('b', 2);
cache.set('c', 3);
cache.set('d', 4);

console.log(cache.get('a'));

// undefined

cache.clear();

cache.set('a', 1);
cache.set('b', 2);
cache.set('c', 3);
cache.get('a');
cache.set('d', 4);

console.log(cache.get('a'));

// 1

About

Key-value least-recently-used (LRU) cache module written in Typescript with zero dependencies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published