CacheImpl

cache/CacheImpl~ CacheImpl

Configurable generic implementation of the Cache interface.

Constructor

new CacheImpl(cacheStorage, factory, Helper, configopt)

Source:
Initializes the cache.
Example
if (cache.has('model.articles')) {
    return cache.get('model.articles');
  } else {
    let articles = getArticlesFromStorage();
    // cache for an hour
    cache.set('model.articles', articles, 60 * 60 * 1000);
  }
Parameters:
Name Type Attributes Default Description
cacheStorage Storage The cache entry storage to use.
factory CacheFactory Which create new instance of cache entry.
Helper vendor.$Helper The IMA.js helper methods.
config Object <optional>
{ttl: 30000, enabled: false} The cache configuration.

Members

_cache :Storage

Source:
Cache entry storage.
Type:
  • Storage

_enabled :boolean

Source:
Flag signalling whether the cache is currently enabled.
Type:
  • boolean

_factory :CacheFactory

Source:
Type:
  • CacheFactory

_Helper :vendor.$Helper

Source:
Tha IMA.js helper methods.
Type:
  • vendor.$Helper

_ttl :number

Source:
Default cache entry time to live in milliseconds.
Type:
  • number

Methods

_canSerializeValue(value) → {boolean}

Source:
Tests whether the provided value can be serialized into JSON.
Parameters:
Name Type Description
value * The value to test whether or not it can be serialized.
Returns:
true if the provided value can be serialized into JSON, false otherwise.
Type
boolean

_clone(value) → {*}

Source:
Attempts to clone the provided value, if possible. Values that cannot be cloned (e.g. promises) will be simply returned.
Parameters:
Name Type Description
value * The value to clone.
Returns:
The created clone, or the provided value if the value cannot be cloned.
Type
*

clear()

Source:

delete()

Source:

deserialize()

Source:

disable()

Source:

enable()

Source:

get()

Source:

has()

Source:

serialize()

Source:

set()

Source: