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:
parent
e1a540b5fa
commit
b40f057594
4 changed files with 55 additions and 32 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue