You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
845 B
34 lines
845 B
3 years ago
|
import {Awaitable} from "../support/types"
|
||
|
|
||
3 years ago
|
/**
|
||
3 years ago
|
* Abstract interface class for a cached object.
|
||
3 years ago
|
*/
|
||
|
export abstract class Cache {
|
||
|
/**
|
||
|
* Fetch a value from the cache by its key.
|
||
|
* @param {string} key
|
||
|
* @return Promise<any|undefined>
|
||
|
*/
|
||
3 years ago
|
public abstract fetch(key: string): Awaitable<string|undefined>;
|
||
3 years ago
|
|
||
|
/**
|
||
|
* Store the given value in the cache by key.
|
||
|
* @param {string} key
|
||
|
* @param {string} value
|
||
|
*/
|
||
3 years ago
|
public abstract put(key: string, value: string): Awaitable<void>;
|
||
3 years ago
|
|
||
|
/**
|
||
|
* Check if the cache has the given key.
|
||
|
* @param {string} key
|
||
|
* @return Promise<boolean>
|
||
|
*/
|
||
3 years ago
|
public abstract has(key: string): Awaitable<boolean>;
|
||
3 years ago
|
|
||
|
/**
|
||
|
* Drop the given key from the cache.
|
||
|
* @param {string} key
|
||
|
*/
|
||
3 years ago
|
public abstract drop(key: string): Awaitable<void>;
|
||
3 years ago
|
}
|