Files
Tony 08a38f0a5e refactor: typing house-keeping (#23074)
* refactor: typing house-keeping

* fix: fix parse date not accepting strict mode

* refactor: use npm package

* fix: address review
2026-08-22 23:58:30 +08:00

26 lines
721 B
TypeScript

import type Redis from 'ioredis';
import type { LRUCache } from 'lru-cache';
type CacheModule = {
init: () => void;
get: (key: string, refresh?: boolean) => Promise<string | null> | string | null;
has: (key: string) => Promise<boolean> | boolean;
set: <T>(key: string, value?: string | T, maxAge?: number) => any;
status: {
available: boolean;
};
clients: {
redisClient?: Redis;
memoryCache?: LRUCache<string, string>;
};
};
export const stringify = <T>(value?: string | T): string => {
if (!value || value === 'undefined') {
return '';
}
return Object(value) === value ? JSON.stringify(value) : String(value);
};
export default CacheModule;