UNPKG

@ima/core

Version:

IMA.js framework for isomorphic javascript application

106 lines (105 loc) 3.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "Cache", { enumerable: true, get: function() { return Cache; } }); class Cache { /** * Clears the cache by deleting all entries. */ clear() { return; } /** * Tests whether the cache contains a fresh entry for the specified key. A * cache entry is fresh if the has not expired its TTL (time to live). * * The method always returns `false` if the cache is currently disabled. * * @param key The identifier of the cache entry. * @return `true` if the cache is enabled, the entry exists and has * not expired yet. */ has(key) { return false; } /** * Returns the value of the entry identified by the specified key. * * The method returns `null` if the specified entry does not exist, has * already expired, or the cache is currently disabled. * * @param key The identifier of the cache entry. * @return The value of the specified cache entry, or `null` if the entry * is not available. */ get(key) { return null; } /** * Sets the cache entry identified by the specified key to the provided * value. The entry is created if it does not exist yet. * * The method has no effect if the cache is currently disabled. * * @param key The identifier of the cache entry. * @param value The cache entry value. * @param ttl Cache entry time to live in milliseconds. The * entry will expire after the specified amount of milliseconds. Use * `null` or omit the parameter to use the default TTL of this cache. */ set(key, value, ttl) { return; } /** * Deletes the specified cache entry. The method has no effect if the entry * does not exist. * * @param key The identifier of the cache entry. */ delete(key) { return; } /** * Disables the cache, preventing the retrieval of any cached entries and * reporting all cache entries as non-existing. Disabling the cache does * not however prevent modifying the existing or creating new cache * entries. * * Disabling the cache also clears all of its current entries. * * The method has no effect if the cache is already disabled. */ disable() { return; } /** * Enables the cache, allowing the retrieval of cache entries. * * The method has no effect if the cache is already enabled. */ enable() { return; } /** * Exports the state of this cache to an HTML-safe JSON string. The data * obtained by parsing the result of this method are compatible with the * {@link Cache#deserialize} method. * * @return A JSON string containing an object representing of the * current state of this cache. */ serialize() { return ''; } /** * Loads the provided serialized cache data into this cache. Entries * present in this cache but not specified in the provided data will remain * in this cache intact. * * @param serializedData An * object representing the state of the cache to load, obtained by * parsing the JSON string returned by the {@link Cache#serialize} * method. */ deserialize(serializedData) { return; } } //# sourceMappingURL=Cache.js.map