Skip to content

Latest commit

 

History

History
241 lines (173 loc) · 6.82 KB

DOCS.md

File metadata and controls

241 lines (173 loc) · 6.82 KB

Classes

CashrEventEmitter

Typedefs

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

Cashr ⇐ EventEmitter

Kind: global class
Extends: EventEmitter

cashr.timeouts : Map.<string, number>

The map of timeouts

Kind: instance property of Cashr
Read only: true

cashr.storage : Map.<string, any>

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

cashr.size : number

The size of this cache

Kind: instance property of Cashr
Read only: true

cashr.values : Array.<any>

The values of this cache

Kind: instance property of Cashr
Read only: true

cashr.keys : Array.<string>

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

cashr.set(key, value, [options])

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 }

cashr.delete(key) ⇒

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

cashr.has(key) ⇒ boolean

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

cashr.clear()

Clears all data from the cache

Kind: instance method of Cashr

cashr._cancelTimeout(key) ⇒ boolean

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

cashr._startTimeout(key)

Starts a timeout for a key

Kind: instance method of Cashr

Param Type Description
key string The key to time out

"valueTimeout" (key, value)

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

Cashr.Cashr

Kind: static class of Cashr

new Cashr(settings)

Constructs a new cache

Param Type
settings CacheOptions

GetOptions : Object

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

SetOptions : Object

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

CacheOptions : Object

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

CacheEntry : Object

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