duckengine
Version:
A 2D Game Engine for the web.
86 lines (85 loc) • 2.63 kB
TypeScript
/**
* @class CacheManager
* @classdesc Creates a CacheManager
* @description The CacheManager Class. Manages Cached items in memory and in storage
* @since 2.0.0
*/
export default class CacheManager {
protected cache: {
[key: string]: string;
};
/**
* @memberof CacheManager
* @description Added start of every key that is stored in the localStorage, defaults to "DuckEngine_CacheManager_${key}"
* @type string
* @since 2.0.0
*/
storageIdentifier: string;
/**
* @constructor CacheManager
* @description Creates a CacheManager instance
* @since 2.0.0
*/
constructor();
sync(): void;
/**
* @memberof CacheManager
* @description Sets a Key-Value pair in the memory-cache and storage
* @param {string} name Name/Key to save the value to
* @param {string} value Value to save to the Name/Key
* @since 2.0.0
*/
set(name: string, value: string): void;
/**
* @memberof CacheManager
* @description Gets a value from a Name/Key from the storage or memory-cache
* @param {string} name Name/Key to get the value from
* @returns {string}
* @since 2.0.0
*/
get(name: string): string | undefined | null;
/**
* @memberof CacheManager
* @description Deletes a Key-Value pair from the memory-cache and storage
* @param {string} name Name/Key to use to delete the pair
* @since 2.0.0
*/
delete(name: string): void;
/**
* @memberof CacheManager
* @description Gets a Key-Value pair from the storage or memory-cache and returns based on if it exists or not
* @param {string} name Name/Key to save the value to
* @since 2.0.0
*/
has(name: string): boolean;
/**
* @memberof CacheManager
* @description Returns the keys from the memory-cache
* @returns {string[]}
* @since 2.0.0
*/
keys(): string[];
/**
* @memberof CacheManager
* @description Returns the values from the memory-cache
* @returns {string[]}
* @since 2.0.0
*/
values(): string[];
/**
* @memberof CacheManager
* @description Loops through each entry in the memory-cache
* @param { (key:string,value:string) => any } cb Callback function
* @since 2.0.0
*/
each(cb: (key: string, value: string) => any): void;
/**
* @memberof CacheManager
* @description Returns the memory-cache entries as an object, calls CacheManager.sync
* @returns {{[key: string]: string}}
* @since 2.0.0
*/
get entries(): {
[key: string]: string;
};
}