Skip to content

📦 A simple in-memory cache that can hold a fixed number of key value pairs

Notifications You must be signed in to change notification settings

saiteja-madha/fixedsize-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Fixed Size Map is a Javascript implementation of Map to hold a limited number of keys

Advantages

  • Simple to use cache
  • Lightweight

Installation

npm i fixedsize-map

Usage

const FixedSizeMap = require("fixedsize-map");

const cache = new FixedSizeMap(100);

// Adding elements to cache
cache.add("k1", "Some Value");
cache.add("k2", "Some Value");

Available Methods

Method Description
add(k, v) Adds a key and pairs it with a value
contains(k) Checks if this cache contains a key
get(k) Retrieves a value from this cache corresponding to the specified key
remove(k) Removed the key value entry from this cache corresponding to the specified key
clear() Clears the cache

About

📦 A simple in-memory cache that can hold a fixed number of key value pairs

Resources

Stars

Watchers

Forks