Cache Plugin
#
Use casesThis plugin acts on the task spawning process: each call of the task is tagged with a (non-unique) key, and task outputs are stored by key. When a task spawns with a cached key, the task is aborted and the cached response is returned. Moreover, cache is common among all the components that connect (maybe inderectly) the RocketJump Partial
where the cache is introduced. This is particularly useful in read-only environments.
#
ConfigurationThis plugin supports some configuration options:
- key: The keyMaker function used to tag each task run with a key deducing it by the spawning parameters
- size: The maximum number of entries to be kept in the cache
- store: The place where the cache is stored. Available stores can be imported from the plugin file, and are
InMemoryStore
,LocalStorageStore
andSessionStorageStore
- provider: The policy used to organize the cache. Possible policies can be imported from the plugin file, and are
LRUCache
andFIFOCache
- ns: A unique identifier used to separate caches for different
RocketJump Objects
#
Usage#
ActionsThis plugin injects in the actions
bag the following action creators:
- resetCache: removes all the items from the cache associated with the
ns
given in the configuration
#
Store details#
SessionStorageStore and LocalStorageStoreThese stores are supported, respectively, by SessionStorage
and LocalStorage
native objects. A key is created in them for any cached item, and has the shape {ns}-{task_key}
. In order to clear the cache, the native localStorage.clear()
and sessionStorage.clear()
should be used.
#
InMemoryStorageThis store is supported by a global variable set outside the application scope. A key is created in this object for any cached item, and has the shape {ns}-{task_key}
. In order to clear the cache, the helper clearInMemoryStore()
exported from the plugin file should be used.