adonis5-cache
Version:
Cache provider for AdonisJS 5
32 lines (31 loc) • 1.25 kB
TypeScript
import { CacheContextContract, CacheStorageContract, TaggableStorageContract } from '@ioc:Adonis/Addons/Adonis5-Cache';
interface InMemoryRecord {
recordExpirationTime: string;
recordValue: string;
}
declare type InMemoryCacheCollection = {
cacheRecords: {
[key: string]: InMemoryRecord;
};
tags: {
[key: string]: string[];
};
};
export default class InMemoryStorage implements CacheStorageContract, TaggableStorageContract {
protected cacheStorage: InMemoryCacheCollection;
constructor();
private get initCacheStorage();
get<T = any>(context: CacheContextContract, key: string): Promise<T | null>;
getMany<T = any>(context: CacheContextContract, keys: string[]): Promise<(T | null)[]>;
put<T = any>(context: CacheContextContract, key: string, value: T, ttl: number): Promise<void>;
putMany<T = any>(context: CacheContextContract, cacheDictionary: {
[p: string]: T;
}, ttl: number): Promise<void>;
flush(): Promise<void>;
forget(key: string): Promise<boolean>;
addTag(tag: string, tagData: string): Promise<void>;
readTag(tag: string): Promise<string[]>;
removeTag(tag: string): Promise<void>;
resolveTtl(ttlInMl: number): number;
}
export {};