mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
28 lines
685 B
TypeScript
28 lines
685 B
TypeScript
import { CacheItem, Client, Policy, EnginePrototypeOrObject } from "catbox";
|
|
|
|
const Memory: EnginePrototypeOrObject = {
|
|
async start(): Promise<void> {},
|
|
stop(): void {},
|
|
async get(): Promise<null | CacheItem> {},
|
|
async set(): Promise<void> {},
|
|
async drop(): Promise<void> {},
|
|
isReady(): boolean { return true; },
|
|
validateSegmentName(segment: string): null { return null; },
|
|
};
|
|
|
|
const client = new Client(Memory, { partition: 'cache' });
|
|
|
|
const cache = new Policy({
|
|
expiresIn: 5000,
|
|
}, client, 'cache');
|
|
|
|
cache.set('foo', 'bar', 5000).then(() => {});
|
|
|
|
cache.get('foo').then(() => {});
|
|
|
|
cache.drop('foo').then(() => {});
|
|
|
|
cache.isReady();
|
|
|
|
cache.stats();
|