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
|
- Source:
Methods
-
flushCache()
-
Clear / Reset the cache and timers. Emits
flush-completeevent with stats upon completion.- Source:
Fires:
-
get(key)
-
Get
keyfrom cache object.Parameters:
Name Type Description keystring - 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
keyis present in cache object.Parameters:
Name Type Description keystring - Source:
Returns:
- Type
- boolean
-
set(key, value)
-
Set
keywithvalueon cache object. Cache Expiry is also handled in this method.Parameters:
Name Type Description keystring valueany - Source:
Events
-
flush-complete
-
Flush Complete Event, good for tests.
Type: object
- Source:
Properties:
Name Type Description statusboolean Indicates status.
nTimeoutsnumber Number of timeouts cleared.
nKeysnumber Number of cache items cleared.