Cache
Members
policy : Map<string|RegExp, number>
policy : Map<string|RegExp, number>The cache policies that this application uses.
storage : any
storage : anyAny 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.
Methods
constructor(storage)
constructor(storage)Create a cache instance that can be used in the SDK.
storageshould match thestoragemember;
const myCache = new Cache(window.localStorage)async cache(key, callback)
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)
invalidate(key)Remove a key or a cache group from the cache.
keymust be a string that matches the cache key or a regular expression;
addPolicy(key, lifespan)
addPolicy(key, lifespan)Add a new cache policy to the cache object.
keymust be a string that matches the cache key or a regular expression;lifespanspecifies for how long the cache object should be valid in seconds;
static use(cacheBuilder)
static use(cacheBuilder)Use a specific cache object for the global cache.
cacheBuildermust be a function that returnsCache;
static get()
static get()Get the global cache object.
Helpers
async function cache(key, callback)
async function cache(key, callback)Cache something globally.
function invalidate(key)
function invalidate(key)Invalidate something from global cache.
escapePolicyPart(string)
escapePolicyPart(string)Escape a variable to be used in a regex.
Last updated