Class puredom.Cache
-
In-memeory cache class with a twist!
Set and get work like a normal cache. Creates a new Cache instance. - Defined in: utils.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Field Attributes | Field Name and Description |
|---|---|
|
The default *type* used for namespacing keys is "_default"
|
Method Summary
| Method Attributes | Method Name and Description |
|---|---|
|
each
(iterator)
Iterate over all the cache entries.
|
|
|
get
(type, id, callback)
Get a cached value with optional type.
|
|
|
proxySet
(type, id, callback, paramIndex)
Proxy a callback function for automatically caching asynchronous responses.
|
|
|
purge
()
Purge all entries from the cache
|
|
|
set
(type, id, value)
Get a cached value with optional type.
|
Class Detail
puredom.Cache()
Field Detail
defaultType
The default *type* used for namespacing keys is "_default"
Method Detail
-
each(iterator)Iterate over all the cache entries.
- Parameters:
- {Function} iterator
- Gets passed each entry.
-
get(type, id, callback)Get a cached value with optional type.
- Parameters:
- {String} type Optional
- A type prefix.
- {String|Number} id
- The cache entry ID
- {Function} callback
- A callback, gets passed the cached value once retrieved.
-
{Function} proxySet(type, id, callback, paramIndex)Proxy a callback function for automatically caching asynchronous responses.
- Parameters:
- {String} type Optional
- A type prefix.
- {String|Number} id
- The cache entry ID
- {Function} callback
- The callback function to inject c
- {Number} paramIndex
- Which callback parameter to cache (0-based).
- Returns:
- {Function} The proxied callback function, with the cache set injected.
-
purge()Purge all entries from the cache
-
set(type, id, value)Get a cached value with optional type.
- Parameters:
- {String} type Optional
- A type prefix.
- {String|Number} id
- The cache entry ID
- {Any}value
- Any value to cache.