NapCatQQ/packages/napcat-common/src/store.ts
手瓜一十雪 26e84653d6 Add ESLint config and update code style
Introduced a new eslint.config.js using neostandard and added related devDependencies. Updated codebase for consistent formatting, spacing, and function declarations. Minor refactoring and cleanup across multiple files to improve readability and maintain code style compliance.
2025-11-15 16:21:59 +08:00

23 lines
465 B
TypeScript

class Store {
private store = new Map<string, any>();
set<T> (key: string, value: T, ttl?: number): void {
this.store.set(key, value);
if (ttl) {
setTimeout(() => this.store.delete(key), ttl * 1000);
}
}
get<T> (key: string): T | null {
return this.store.get(key) ?? null;
}
exists (...keys: string[]): number {
return keys.filter(key => this.store.has(key)).length;
}
}
const store = new Store();
export default store;