1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Cache AP video route for 5 seconds

This commit is contained in:
Chocobozzz 2018-05-11 09:44:04 +02:00
parent 8a2db2e8cb
commit fd4484f19e
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 42 additions and 30 deletions

View file

@ -2,7 +2,7 @@ import * as express from 'express'
import { createClient, RedisClient } from 'redis'
import { logger } from '../helpers/logger'
import { generateRandomString } from '../helpers/utils'
import { CONFIG, FEEDS, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../initializers'
import { CONFIG, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../initializers'
type CachedRoute = {
body: string,
@ -67,14 +67,14 @@ class Redis {
return cached as CachedRoute
}
setCachedRoute (req: express.Request, body: any, contentType?: string, statusCode?: number) {
setCachedRoute (req: express.Request, body: any, lifetime: number, contentType?: string, statusCode?: number) {
const cached: CachedRoute = {
body: body.toString(),
contentType,
statusCode: statusCode.toString()
}
return this.setObject(this.buildCachedRouteKey(req), cached, FEEDS.CACHE_LIFETIME)
return this.setObject(this.buildCachedRouteKey(req), cached, lifetime)
}
listJobs (jobsPrefix: string, state: string, mode: 'alpha', order: 'ASC' | 'DESC', offset: number, count: number) {