X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fmiddlewares%2Fcache%2Fcache.ts;h=6041c76c3ce75e861036de4b5f8a07ef959af5f9;hb=cb0eda5602a21d1626a7face32de6153ed07b5f9;hp=48162a0ae7048793f29631279ef33990543a807f;hpb=20bafcb61bee2a9a10a500908850c9a7d5e3c8c5;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/cache/cache.ts b/server/middlewares/cache/cache.ts index 48162a0ae..6041c76c3 100644 --- a/server/middlewares/cache/cache.ts +++ b/server/middlewares/cache/cache.ts @@ -1,10 +1,6 @@ import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' -import { Redis } from '../../lib/redis' import { ApiCache, APICacheOptions } from './shared' -// Ensure Redis is initialized -Redis.Instance.init() - const defaultOptions: APICacheOptions = { excludeStatus: [ HttpStatusCode.FORBIDDEN_403, @@ -21,12 +17,22 @@ function cacheRoute (duration: string) { function cacheRouteFactory (options: APICacheOptions) { const instance = new ApiCache({ ...defaultOptions, ...options }) - return instance.buildMiddleware.bind(instance) + return { instance, middleware: instance.buildMiddleware.bind(instance) } +} + +// --------------------------------------------------------------------------- + +function buildPodcastGroupsCache (options: { + channelId: number +}) { + return 'podcast-feed-' + options.channelId } // --------------------------------------------------------------------------- export { cacheRoute, - cacheRouteFactory + cacheRouteFactory, + + buildPodcastGroupsCache }