The BaseCache is a base Cache class that can be used for storing references to any kind of data.
Data can be added, retrieved and removed based on the given keys.
Keys are string-based.
new BaseCache()
The Map in which the cache objects are stored.
You can query the Map directly or use the BaseCache methods.
An instance of EventEmitter used by the cache to emit related events.
Adds an item to this cache. The item is referenced by a unique string, which you are responsible for setting and keeping track of. The item can only be retrieved by using this string.
name | type | description |
---|---|---|
key | string |
The unique key by which the data added to the cache will be referenced. |
data | * |
The data to be stored in the cache. |
This BaseCache object.
Destroys this cache and all items within it.
Checks if this cache contains an item matching the given key.
This performs the same action as BaseCache.has
and is called directly by the Loader.
name | type | description |
---|---|---|
key | string |
The unique key of the item to be checked in this cache. |
Returns true
if the cache contains an item matching the given key, otherwise false
.
Gets an item from this cache based on the given key.
name | type | description |
---|---|---|
key | string |
The unique key of the item to be retrieved from this cache. |
The item in the cache, or null
if no item matching the given key was found.
Returns all keys in use in this cache.
Array containing all the keys.
Checks if this cache contains an item matching the given key.
This performs the same action as BaseCache.exists
.
name | type | description |
---|---|---|
key | string |
The unique key of the item to be checked in this cache. |
Returns true
if the cache contains an item matching the given key, otherwise false
.
Removes and item from this cache based on the given key.
If an entry matching the key is found it is removed from the cache and a remove
event emitted.
No additional checks are done on the item removed. If other systems or parts of your game code
are relying on this item, it is up to you to sever those relationships prior to removing the item.
name | type | description |
---|---|---|
key | string |
The unique key of the item to remove from the cache. |
This BaseCache object.