mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-05 10:10:30 +08:00
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.
23 lines
465 B
TypeScript
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;
|