aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/redis.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-11 09:44:04 +0200
committerChocobozzz <me@florianbigard.com>2018-05-11 15:24:17 +0200
commitfd4484f19eae8b0a0c30d5d30e98880c8708516a (patch)
tree9dcb357413c84797b79e301fb843b1695e20d902 /server/lib/redis.ts
parent8a2db2e8cb67f7f802ecb35be7b9154695f1a6ec (diff)
downloadPeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.tar.gz
PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.tar.zst
PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.zip
Cache AP video route for 5 seconds
Diffstat (limited to 'server/lib/redis.ts')
-rw-r--r--server/lib/redis.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index 1e7c0a821..0acb9ff0e 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { createClient, RedisClient } from 'redis' 2import { createClient, RedisClient } from 'redis'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4import { generateRandomString } from '../helpers/utils' 4import { generateRandomString } from '../helpers/utils'
5import { CONFIG, FEEDS, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../initializers' 5import { CONFIG, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../initializers'
6 6
7type CachedRoute = { 7type CachedRoute = {
8 body: string, 8 body: string,
@@ -67,14 +67,14 @@ class Redis {
67 return cached as CachedRoute 67 return cached as CachedRoute
68 } 68 }
69 69
70 setCachedRoute (req: express.Request, body: any, contentType?: string, statusCode?: number) { 70 setCachedRoute (req: express.Request, body: any, lifetime: number, contentType?: string, statusCode?: number) {
71 const cached: CachedRoute = { 71 const cached: CachedRoute = {
72 body: body.toString(), 72 body: body.toString(),
73 contentType, 73 contentType,
74 statusCode: statusCode.toString() 74 statusCode: statusCode.toString()
75 } 75 }
76 76
77 return this.setObject(this.buildCachedRouteKey(req), cached, FEEDS.CACHE_LIFETIME) 77 return this.setObject(this.buildCachedRouteKey(req), cached, lifetime)
78 } 78 }
79 79
80 listJobs (jobsPrefix: string, state: string, mode: 'alpha', order: 'ASC' | 'DESC', offset: number, count: number) { 80 listJobs (jobsPrefix: string, state: string, mode: 'alpha', order: 'ASC' | 'DESC', offset: number, count: number) {