caching-library

1.0.0 • Public • Published

caching-library

Implementation of cache managed via eviction policies like FIFO, LRU and LIFO.

  • FIFO: First In First Out, the first value in the cache is replaced.
  • LRU: Last Recently Used, the last recently used value cached is replaced.
  • LIFO: Last In First Out, the last value in the cache is replaced.

Usage

const Caches = require('caches')

//To create a cache using a specific eviction policy
const lru = new Caches.lru()
const lifo = new Caches.lifo()
const fifo = new Caches.fifo()

Functions

//Methods
get (key) //Get the value from the cache with the specific key
set (key, value) //Sets the key and the value pair in the cache if it doesn't exist
has (key) //checks if the value for the given key exists in the cache
clear() //clears the cache 
del(key) //delete the value for the given key
size() //get the size of the cache
keys() //get all the keys that exist in the cache
values() //get all the values that exist in the cache

For Running Tests

npm test

Readme

Keywords

none

Package Sidebar

Install

npm i caching-library

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

14.6 kB

Total Files

12

Last publish

Collaborators

  • waridrox