aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/redis.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-06 08:50:43 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commitac907dc7c158056e9b6a5cb58acd27df5c7c2670 (patch)
treef9d8bff22e0543a305c64e1a1808c0df6d512f1e /server/lib/redis.ts
parentdfbcefc20dc64f0814b1f2e8e782a4ea1bd24db2 (diff)
downloadPeerTube-ac907dc7c158056e9b6a5cb58acd27df5c7c2670.tar.gz
PeerTube-ac907dc7c158056e9b6a5cb58acd27df5c7c2670.tar.zst
PeerTube-ac907dc7c158056e9b6a5cb58acd27df5c7c2670.zip
Improve viewer counter
More precise, avoid weird decrease, reuse an id to federate viewers
Diffstat (limited to 'server/lib/redis.ts')
-rw-r--r--server/lib/redis.ts12
1 files changed, 0 insertions, 12 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index f9cea57cd..d052de786 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -145,18 +145,10 @@ class Redis {
145 return this.setValue(this.generateIPViewKey(ip, videoUUID), '1', VIEW_LIFETIME.VIEW) 145 return this.setValue(this.generateIPViewKey(ip, videoUUID), '1', VIEW_LIFETIME.VIEW)
146 } 146 }
147 147
148 setIPVideoViewer (ip: string, videoUUID: string) {
149 return this.setValue(this.generateIPViewerKey(ip, videoUUID), '1', VIEW_LIFETIME.VIEWER_COUNTER)
150 }
151
152 async doesVideoIPViewExist (ip: string, videoUUID: string) { 148 async doesVideoIPViewExist (ip: string, videoUUID: string) {
153 return this.exists(this.generateIPViewKey(ip, videoUUID)) 149 return this.exists(this.generateIPViewKey(ip, videoUUID))
154 } 150 }
155 151
156 async doesVideoIPViewerExist (ip: string, videoUUID: string) {
157 return this.exists(this.generateIPViewerKey(ip, videoUUID))
158 }
159
160 /* ************ Tracker IP block ************ */ 152 /* ************ Tracker IP block ************ */
161 153
162 setTrackerBlockIP (ip: string) { 154 setTrackerBlockIP (ip: string) {
@@ -361,10 +353,6 @@ class Redis {
361 return `views-${videoUUID}-${ip}` 353 return `views-${videoUUID}-${ip}`
362 } 354 }
363 355
364 private generateIPViewerKey (ip: string, videoUUID: string) {
365 return `viewer-${videoUUID}-${ip}`
366 }
367
368 private generateTrackerBlockIPKey (ip: string) { 356 private generateTrackerBlockIPKey (ip: string) {
369 return `tracker-block-ip-${ip}` 357 return `tracker-block-ip-${ip}`
370 } 358 }