UNPKG

express-redis-simple-cache

Version:

A simple and effective Redis-based caching middleware for Express.js APIs.

23 lines (19 loc) 738 B
import { RedisClientOptions, createClient } from 'redis'; import { RequestHandler } from 'express'; type LogLevel = 'normal' | 'debug' | 'silent'; type Route = { method: string; route: string; cache?: { expire?: number; type: 'always' | 'per-auth-token' | 'per-request-url'; } | { expire?: number; type: 'per-custom-cookie'; customCookie?: string; }; }; declare function setupCache(redisClientOptions: RedisClientOptions, logLevel: LogLevel): Promise<ReturnType<typeof createClient>>; declare function stopCache(redis: ReturnType<typeof createClient>): Promise<void>; declare function cache(route: Route): RequestHandler; export { type Route, cache, setupCache, stopCache };