Class: CacheStore

CacheStore

Cache Store Class


new CacheStore( [ttl] [, config])

Creates an instance of CacheStore.

Parameters:
Name Type Argument Description
ttl number <optional>

TTL value for cache items in minutes.

config object <optional>

Config / Options object.

Properties
Name Type Argument Description
maxSize number <optional>

Maximum number of items to be stored in cache.

Source:

Methods


flushCache()

Clear / Reset the cache and timers. Emits flush-complete event with stats upon completion.

Source:
Fires:

get(key)

Get key from cache object.

Parameters:
Name Type Description
key string
Source:
Returns:
Type
any

getQueueSize()

Get the number of elements present in queue. Useful for tests.

Source:
Returns:

Number of elements in queue.

Type
number

getSize()

Get the number of elements present in cache object. Useful for tests.

Source:
Returns:

Number of elements in cache.

Type
number

has(key)

Check whether key is present in cache object.

Parameters:
Name Type Description
key string
Source:
Returns:
Type
boolean

set(key, value)

Set key with value on cache object. Cache Expiry is also handled in this method.

Parameters:
Name Type Description
key string
value any
Source:

Events


flush-complete

Flush Complete Event, good for tests.

Type: object
Properties:
Name Type Description
status boolean

Indicates status.

nTimeouts number

Number of timeouts cleared.

nKeys number

Number of cache items cleared.

Source: