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

Handle concurrent requests in cache middleware

This commit is contained in:
Chocobozzz 2018-05-23 10:03:26 +02:00
parent e1a540b5fa
commit b40f057594
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 55 additions and 32 deletions

View file

@ -88,6 +88,18 @@ class Redis {
})
}
generateResetPasswordKey (userId: number) {
return 'reset-password-' + userId
}
buildViewKey (ip: string, videoUUID: string) {
return videoUUID + '-' + ip
}
buildCachedRouteKey (req: express.Request) {
return req.method + '-' + req.originalUrl
}
private getValue (key: string) {
return new Promise<string>((res, rej) => {
this.client.get(this.prefix + key, (err, value) => {
@ -146,18 +158,6 @@ class Redis {
})
}
private generateResetPasswordKey (userId: number) {
return 'reset-password-' + userId
}
private buildViewKey (ip: string, videoUUID: string) {
return videoUUID + '-' + ip
}
private buildCachedRouteKey (req: express.Request) {
return req.method + '-' + req.originalUrl
}
static get Instance () {
return this.instance || (this.instance = new this())
}