nextjs-redis-cache
Version:
A Redis Cache for Next.js Framework that supports expiration after a given time and also compress the data in memory.
15 lines (14 loc) • 610 B
TypeScript
import { createClient } from 'redis';
declare type CacheOptions = {
expireIn?: number;
};
declare type RedisClientType = ReturnType<typeof createClient>;
declare type CacheGetType<D = any> = Promise<D>;
declare class RedisCache {
exists: (client: RedisClientType, key: string) => Promise<boolean>;
delete: (client: RedisClientType, keys: string[]) => Promise<number>;
get: (client: RedisClientType, key: string) => CacheGetType<any>;
set: (client: RedisClientType, key: string, payload: any, options?: CacheOptions) => Promise<boolean>;
}
export declare const cache: RedisCache;
export {};