Module cache
Generic LRU cache implementation, used for both query and
entity caches within a Store instance.
Creates a new Cache instance
Parameters
Number |
size |
Optional cache size, defaults to 1000 |
Returns
|
A newly created Cache instance |
Returns true if the cache contains the given key
Returns
Boolean |
True if the cache contains the given key, false otherwise |
Cache.prototype.get
(key)
Returns the cached value for the given key
Cache.prototype.isEmpty
()
Returns true if the cache is empty
Returns
Boolean |
True if the cache is empty, false otherwise |
Cache.prototype.put
(key, value)
Adds the value with the given key into the cache
Parameters
Object |
key |
The cache key |
Object |
value |
The value |
Cache.prototype.remove
(key)
Removes the cached value for the given key
Cache.prototype.size
()
Returns the number of objects in the cache
Returns
Number |
The number of objects in the cache |
Parameters
String |
typeOrKey |
Either an entity key, or a type string |
Number |
id |
The ID of the entity |