diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-11 09:44:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:24:17 +0200 |
commit | fd4484f19eae8b0a0c30d5d30e98880c8708516a (patch) | |
tree | 9dcb357413c84797b79e301fb843b1695e20d902 /server/lib | |
parent | 8a2db2e8cb67f7f802ecb35be7b9154695f1a6ec (diff) | |
download | PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.tar.gz PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.tar.zst PeerTube-fd4484f19eae8b0a0c30d5d30e98880c8708516a.zip |
Cache AP video route for 5 seconds
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/redis.ts | 6 |
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' | |||
2 | import { createClient, RedisClient } from 'redis' | 2 | import { createClient, RedisClient } from 'redis' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { generateRandomString } from '../helpers/utils' | 4 | import { generateRandomString } from '../helpers/utils' |
5 | import { CONFIG, FEEDS, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../initializers' | 5 | import { CONFIG, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../initializers' |
6 | 6 | ||
7 | type CachedRoute = { | 7 | type 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) { |