The following caches are managed by the SDK and active by default. They are in-memory caches.
Caches can be cleared at any time
client.clearOptionCache(); client.clearMethodCache(); client.clearEntityCache();
or
client.clearAllCaches();
Caches have a TTL of 5 minutes by default. The TTL can be changed at connection time using connection options entityCacheTTL, methodCacheTTL, and optionCacheTTL.
Caches can be de-activated by setting a TTL of -1 which will have the effect of making all cached data always invalid.
In addition to memory caches, it is possible to use persistent caches as well. This was introduced in version 1.0.5 and is active by default as well when using the SDK in a browser. The browser local storage is used (if allowed).
Cached data is stored in local storage with keys prefixed with acc.js.sdk...cache. where version is the SDK version and server is the Campaign server name. This means that the cached data is lost when upgrading the SDK.
It's possible to disable persistent caches using the noStorage connection option.
It is also possible to setup one's own persistent cache, by passing a storage object as a connection option. See the "Custom Storage" section below for more details.
Additionally, since version 1.1.18, the storage object should also support the for...in operator to iterate through its keys
By default, the SDK will prefix all cache entity by a root key, which is made of the SDK version and the instance URL. It is possible to change this using the `cacheRootKey` connection parameter.
The SDK includes a mechnism to maintain the schemas and options caches up-to-date by polling the Campaign server on a regular basis (10 seconds by default). The server returns the list of entities (schemas or options) which have changed since they were cached, and the client removes them from the cache. When a schema changes, the corresponding methods are also removed from the method cache.
This mechanism is not activate by default but can be activated or deactivated by the following functions
client.startRefreshCaches(30000); // activate cache auto-refresh mechanism every 30s client.stopRefreshCaches(); // de-activate cache auto-refresh
This mechanism is based on the xtk:session#GetModifiedEntities SOAP method which is only available in Campaign 8.4 and above only. For other builds of Campaign, the auto-refresh mechanism will not do anything.
The following changes are handled:
The refresh mechanism includes the following guardrails