This AI is still in early stages of development.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Access or invalidate a cached value...

 

Syntax

var value = Cache.key; // get a cached value
 
Cache.key = void Cache; // invalidate a cached value

Getting a cached value

When defining a new cache, using the Cache() function, a "key" is specified. This key becomes a property on the global Cache object, allowing you to retrieve the cached value. If the cache has expired, the value is automatically updated next time you access the property.

For example, if you've defined a "foo" key, you can get it's value as follows:

var foo = Cache.foo; // get a cached value for key "foo"

Invalidating a cache

You can invalidate a cache key at any time, forcing it's value to be updated the next time it is accessed.

For example, if you want to force the "foo" key to refresh its value, do this:

Cache.foo = void Cache; // invalidate the cache for key "foo"
 
var foo = Cache.foo; // generates new value for "foo" key and caches it
You need to define keys first using Cache().

Availability

Requires:

Cache API

Topics:

 

  • No labels