Namespace
Namespace utility for cache module
- Namespace
- Namespace ⏏
- new Namespace(name)
- .set(key, value) ⇒
Object
- .contains(key) ⇒
Object
- .has(key) ⇒
Object
- .rename(before, after) ⇒
Object
- .remove(key) ⇒
Object
- .forEach(cb(value,)
- .clear(name) ⇒
Object
- Namespace ⏏
Namespace ⏏
new Namespace(name)
Create a LRU cache namespace.
Param | Type | Description |
---|---|---|
name | string |
The namespace identifier |
options.limit | number |
The MAX count of cached items |
options.onRemove | function |
The callback when item removed |
namespace.set(key, value) ⇒ Object
Set a cache item and put the item to the tail, while remove the first item when limit overflow.
Kind: instance method of Namespace
Returns: Object
- this
Param | Type | Description |
---|---|---|
key | string |
The key for your cache item |
value | any |
The value for your cache item |
namespace.contains(key) ⇒ Object
Alias to #has
Kind: instance method of Namespace
Returns: Object
- this
Param | Type | Description |
---|---|---|
key | string |
The key to check with |
namespace.has(key) ⇒ Object
Check whether the given key exists within the namespace, or whether the namespace exists if key not set.
Kind: instance method of Namespace
Returns: Object
- this
Param | Type | Description |
---|---|---|
key | string |
The key to check with |
namespace.rename(before, after) ⇒ Object
Rename a cache item
Kind: instance method of Namespace
Returns: Object
- this
Param | Type | Description |
---|---|---|
before | string |
The source key for your cache item |
after | string |
The destination key for your cache item |
namespace.remove(key) ⇒ Object
Remove a specific key
in namespace name
Kind: instance method of Namespace
Returns: Object
- this
Param | Type | Description |
---|---|---|
key | string |
The key to remove |
namespace.forEach(cb(value,)
Traverse all items available
Kind: instance method of Namespace
Param | Type | Description |
---|---|---|
cb(value, | function |
key) The callback to iterate with |
namespace.clear(name) ⇒ Object
Clear the given namespace, or all namespaces if name
not set.
Kind: instance method of Namespace
Returns: Object
- this
Param | Type | Description |
---|---|---|
name | string |
The namespace to clear. |