modrinth
Version:
JavaScript library for accessing the Modrinth API
31 lines (30 loc) • 892 B
TypeScript
export interface CacheOptions {
ttl: number;
capacity: number;
}
export interface CacheData<Item> {
value: Item;
expiry: number;
}
export declare type CacheCallbackFn<Return> = () => Return;
export declare type CacheMap<Item> = {
[key: string]: CacheData<Item>;
};
export declare class Cache<Item = unknown> {
static defaultOptions: CacheOptions;
protected options: Partial<CacheOptions>;
protected data: CacheMap<Item>;
constructor(options?: Partial<CacheOptions>);
get now(): number;
get capacity(): number;
get size(): number;
get empty(): boolean;
get full(): boolean;
get percent(): number;
get<GetItem extends Item>(key: string): GetItem;
has(key: string): boolean;
set(key: string, value: Item, ttl?: number): CacheData<Item>;
prune(amount?: number): void;
delete(key: string): void;
clear(): void;
}