1.2.0 • Published 4 years ago

tiny-fifo v1.2.0

Weekly downloads
3
License
BSD-3-Clause
Repository
github
Last release
4 years ago

tiny-fifo

Tiny FIFO cache for Client or Server

build status

const cache = fifo(max, ttl = 0);

clear

Method

Clears the contents of the cache

return {Object} FIFO instance

Example

cache.clear();

delete

Method

Removes item from cache

param  {String} key Item key
return {Object}     FIFO instance

Example

cache.delete("myKey");

evict

Method

Evicts the first item from cache

return {Object} FIFO instance

Example

cache.evict();

get

Method

Gets item in cache

param  {String} key Item key
return {Mixed}      Undefined or Item value

Example

const item = cache.get("myKey");

keys

Method

Returns an Array of cache item keys

return {Array} Array of keys

Example

console.log(cache.keys());

max

Property

Max items to hold in cache (1000)

Example

const cache = fifo(500);

cache.max; // 500

set

Method

Sets item in cache

param  {String} key   Item key
param  {Mixed}  value Item value
return {Object}       FIFO instance

Example

cache.set("myKey", {prop: true});

size

Property

Number of items in cache

Example

const cache = fifo();

cache.size; // 0 - it's a new cache!

ttl

Property

Milliseconds an item will remain in cache; lazy expiration upon next get() of an item

Example

const cache = fifo();

cache.ttl = 3e4;

License

Copyright (c) 2019 Jason Mulligan Licensed under the BSD-3 license.

1.2.0

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago