- Cashr ⇐
EventEmitter
- GetOptions :
Object
Options to provide to a call to get
- SetOptions :
Object
Options to provide to a call to set
- CacheOptions :
Object
Options to provide to the constructor of a cache
- CacheEntry :
Object
An entry in the cache
Kind: global class
Extends: EventEmitter
- Cashr ⇐
EventEmitter
- instance
- .timeouts :
Map.<string, number>
- .storage :
Map.<string, any>
- .settings :
CacheOptions
- .size :
number
- .values :
Array.<any>
- .keys :
Array.<string>
- .entries :
Array.<CacheEntry>
- .set(key, value, [options])
- .delete(key) ⇒
- .has(key) ⇒
boolean
- .clear()
- ._cancelTimeout(key) ⇒
boolean
- ._startTimeout(key)
- "valueTimeout" (key, value)
- .timeouts :
- static
- instance
The map of timeouts
Kind: instance property of Cashr
Read only: true
The internal storage map
Kind: instance property of Cashr
Read only: true
cashr.settings : CacheOptions
The settings for this cache
Kind: instance property of Cashr
Read only: true
The size of this cache
Kind: instance property of Cashr
Read only: true
The values of this cache
Kind: instance property of Cashr
Read only: true
The keys of this cache
Kind: instance property of Cashr
Read only: true
cashr.entries : Array.<CacheEntry>
The entries of this cache
Kind: instance property of Cashr
Read only: true
Sets a value at a given key
Kind: instance method of Cashr
Param | Type | Default | Description |
---|---|---|---|
key | string |
The key of the property to set | |
value | any |
The value to set | |
[options] | SetOptions |
{ preventTimeout: true } |
Deletes the value at the given key
Kind: instance method of Cashr
Returns: The value that was stored under that key
Param | Type | Description |
---|---|---|
key | string |
The key of the property to delete |
Checks the cache if a value with the given key exists
Kind: instance method of Cashr
Returns: boolean
- Whether or not there is a stored value at the given key
Param | Type | Description |
---|---|---|
key | string |
The key to check |
Clears all data from the cache
Kind: instance method of Cashr
Cancels any timeouts for a given key
Kind: instance method of Cashr
Returns: boolean
- Whether or not there were any timeouts to cancel
Param | Type | Description |
---|---|---|
key | string |
The key to cancel timeouts for |
Starts a timeout for a key
Kind: instance method of Cashr
Param | Type | Description |
---|---|---|
key | string |
The key to time out |
Called when a value times out
Kind: event emitted by Cashr
Param | Type | Description |
---|---|---|
key | string |
The key of the value that timed out |
value | any |
The value that timed out |
Kind: static class of Cashr
Constructs a new cache
Param | Type |
---|---|
settings | CacheOptions |
Options to provide to a call to get
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
default | any |
The default value to return if none is found in storage |
preventTimeout | boolean |
Whether or not to reset the timeout of the value |
Options to provide to a call to set
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
preventTimeout | boolean |
Whether or not to reset the timeout of the value |
Options to provide to the constructor of a cache
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
timeoutDelay | number |
The timeout delay, or 0 to indicate no timeout |
An entry in the cache
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
key | string |
The key of the entry |
value | any |
The value of the entry |