DataStore

DataStore

Fifo size-bound key-value store.

Constructor

new DataStore(size, age, dispose)

Source:

Constructor

Parameters:
Name Type Description
size int

max number of items to store

age int

max life of an object in ms

dispose function

called whenever object is shifted from cache

Members

length

Source:

Length getter

Methods

iterate(f)

Source:

Iterate through all stored items

Parameters:
Name Type Description
f function

function(id, item) to call with every item

read(id) → {Any}

Source:

Read value by key

Parameters:
Name Type Description
id String

key

Returns:

value or undefined if no value under such key is stored

Type
Any

remove(id)

Source:

Remove an item from the store

Parameters:
Name Type Description
id String

id of the item to remove

update(id, set) → {Boolean}

Source:

Update value stored under key with $set-like update

Parameters:
Name Type Description
id String

key

set Object

flattened object of {attr1: 2, 'obj.attr2': 3} kind

Returns:

true if updated, false in case no object is stored under key

Type
Boolean

write(id, data) → {Object}

Source:

Store value

Parameters:
Name Type Description
id String

key

data Object

value (pass null to delete data record)

Returns:

returns the data supplied if it was stored, undefined otherwise

Type
Object