]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/cache/cache.ts
Add Podcast RSS feeds (#5487)
[github/Chocobozzz/PeerTube.git] / server / middlewares / cache / cache.ts
index 48162a0ae7048793f29631279ef33990543a807f..6041c76c3ce75e861036de4b5f8a07ef959af5f9 100644 (file)
@@ -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
 }