mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-17 05:11:57 +08:00
08a38f0a5e
* refactor: typing house-keeping * fix: fix parse date not accepting strict mode * refactor: use npm package * fix: address review
26 lines
721 B
TypeScript
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;
|