2021-03-09 16:16:27 +00:00
|
|
|
/**
|
|
|
|
* Abstract interface class for an application cache object.
|
|
|
|
*/
|
|
|
|
export abstract class Cache {
|
|
|
|
/**
|
|
|
|
* Fetch a value from the cache by its key.
|
|
|
|
* @param {string} key
|
|
|
|
* @return Promise<any|undefined>
|
|
|
|
*/
|
|
|
|
public abstract fetch(key: string): string | undefined | Promise<string | undefined>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the given value in the cache by key.
|
|
|
|
* @param {string} key
|
|
|
|
* @param {string} value
|
2021-03-09 16:38:02 +00:00
|
|
|
* @param {Date} [expires]
|
2021-03-09 16:16:27 +00:00
|
|
|
*/
|
2021-03-09 16:38:02 +00:00
|
|
|
public abstract put(key: string, value: string, expires?: Date): void | Promise<void>;
|
2021-03-09 16:16:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the cache has the given key.
|
|
|
|
* @param {string} key
|
|
|
|
* @return Promise<boolean>
|
|
|
|
*/
|
|
|
|
public abstract has(key: string): boolean | Promise<boolean>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop the given key from the cache.
|
|
|
|
* @param {string} key
|
|
|
|
*/
|
|
|
|
public abstract drop(key: string): void | Promise<void>;
|
|
|
|
}
|