aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-23 10:03:26 +0200
committerChocobozzz <me@florianbigard.com>2018-05-23 10:03:26 +0200
commitb40f057594d51ae64e9d638d3b5877e544214b53 (patch)
treebd7918e8b5ab4f688422125a925cca9b6ff527bc /server/lib
parente1a540b5fa14b0fafa63f99e344927b10fdbee00 (diff)
downloadPeerTube-b40f057594d51ae64e9d638d3b5877e544214b53.tar.gz
PeerTube-b40f057594d51ae64e9d638d3b5877e544214b53.tar.zst
PeerTube-b40f057594d51ae64e9d638d3b5877e544214b53.zip
Handle concurrent requests in cache middleware
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/redis.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index 97ff3598b..5bd55109c 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -88,6 +88,18 @@ class Redis {
88 }) 88 })
89 } 89 }
90 90
91 generateResetPasswordKey (userId: number) {
92 return 'reset-password-' + userId
93 }
94
95 buildViewKey (ip: string, videoUUID: string) {
96 return videoUUID + '-' + ip
97 }
98
99 buildCachedRouteKey (req: express.Request) {
100 return req.method + '-' + req.originalUrl
101 }
102
91 private getValue (key: string) { 103 private getValue (key: string) {
92 return new Promise<string>((res, rej) => { 104 return new Promise<string>((res, rej) => {
93 this.client.get(this.prefix + key, (err, value) => { 105 this.client.get(this.prefix + key, (err, value) => {
@@ -146,18 +158,6 @@ class Redis {
146 }) 158 })
147 } 159 }
148 160
149 private generateResetPasswordKey (userId: number) {
150 return 'reset-password-' + userId
151 }
152
153 private buildViewKey (ip: string, videoUUID: string) {
154 return videoUUID + '-' + ip
155 }
156
157 private buildCachedRouteKey (req: express.Request) {
158 return req.method + '-' + req.originalUrl
159 }
160
161 static get Instance () { 161 static get Instance () {
162 return this.instance || (this.instance = new this()) 162 return this.instance || (this.instance = new this())
163 } 163 }