2.0.4 • Published 4 years ago

simple.cache v2.0.4

Weekly downloads
45
License
ISC
Repository
github
Last release
4 years ago

simple.cache

a simple lru cache


Build StatusCoverage StatusISC LicenseNodeJS

JavaScript Style Guide

api

const SimpleCache = require('simple.cache')

SimpleCache(max) max integer, default to 1000

methods

  • set(key, value) void, set a new entry and value
  • get(key) string or undefined, gets the entry's value from a given key
  • has(key) boolean, check if a given key already exists
  • remove(key) void, remove a given key from the first cache
  • size() integer, get the size of the cache
  • clear() void, clear cache
  • keys() array, returns the keys from the cache
  • dump() object, retrieves the entire cache

example

const SimpleCache = require('simple.cache')

const myCache = SimpleCache()

myCache.set('foo', 123)
myCache.set('bar', 456)

myCache.get('bar')// returns 456

myCache.remove('foo')

myCache.size()// should return 1

myCache.clear()// both caches are reset

props to Dominic Tarr for the amazing LRU algorithm

ISC License (ISC)

2.0.4

4 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.0

7 years ago

1.0.0

7 years ago