Cache
Last updated
Last updated
policy : Map<string|RegExp, number>
The cache policies that this application uses.
storage : any
Any object that can be used as storage, valid values can be {}
, window.localStorage
, window.sessionStorage
or any class that can be used as a key/value storage.
constructor(storage)
Create a cache instance that can be used in the SDK.
storage
should match the member;
async cache(key, callback)
Attempt to get a cached value based on a key, it is not found in the cache, create it from the callback function.
invalidate(key)
Remove a key or a cache group from the cache.
key
must be a string that matches the cache key or a regular expression;
addPolicy(key, lifespan)
Add a new cache policy to the cache object.
key
must be a string that matches the cache key or a regular expression;
lifespan
specifies for how long the cache object should be valid in seconds;
static use(cacheBuilder)
Use a specific cache object for the global cache.
cacheBuilder
must be a function that returns Cache
;
static get()
Get the global cache object.
async function cache(key, callback)
Cache something globally.
function invalidate(key)
Invalidate something from global cache.
escapePolicyPart(string)
Escape a variable to be used in a regex.
This function is an alias for .
This function is an alias for .