summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorMar0xy <marie@kaifa.ch>2023-11-09 14:51:19 +0100
committerMar0xy <marie@kaifa.ch>2023-11-09 14:51:19 +0100
commitfd51854670639b30555ecaa314c552cb82bfb52a (patch)
tree294d56a6422b5ccff4886a922e0969184c36d9cd /packages/backend/src
parentfix: not starting due to duplicate endpoint (diff)
downloadsharkey-fd51854670639b30555ecaa314c552cb82bfb52a.tar.gz
sharkey-fd51854670639b30555ecaa314c552cb82bfb52a.tar.bz2
sharkey-fd51854670639b30555ecaa314c552cb82bfb52a.zip
revert: trending support for redis 6.3
It seems this change has caused redis to periodically crash on big instances
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/FeaturedService.ts14
-rw-r--r--packages/backend/src/core/HashtagService.ts28
2 files changed, 13 insertions, 29 deletions
diff --git a/packages/backend/src/core/FeaturedService.ts b/packages/backend/src/core/FeaturedService.ts
index 7ba707e9e1..9617f83880 100644
--- a/packages/backend/src/core/FeaturedService.ts
+++ b/packages/backend/src/core/FeaturedService.ts
@@ -35,16 +35,10 @@ export class FeaturedService {
`${name}:${currentWindow}`,
score,
element);
-
- const TTL = await this.redisClient.ttl(`${name}:${currentWindow}`);
-
- if (TTL === -1) {
- this.redisClient.expire(`${name}:${currentWindow}`,
- (windowRange * 3) / 1000, // 1時間
- //'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
- );
- }
-
+ redisTransaction.expire(
+ `${name}:${currentWindow}`,
+ (windowRange * 3) / 1000,
+ 'NX'); // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
await redisTransaction.exec();
}
diff --git a/packages/backend/src/core/HashtagService.ts b/packages/backend/src/core/HashtagService.ts
index cc5ce4e964..d378999907 100644
--- a/packages/backend/src/core/HashtagService.ts
+++ b/packages/backend/src/core/HashtagService.ts
@@ -176,30 +176,20 @@ export class HashtagService {
// チャート用
redisPipeline.pfadd(`hashtagUsers:${hashtag}:${window}`, userId);
+ redisPipeline.expire(`hashtagUsers:${hashtag}:${window}`,
+ 60 * 60 * 24 * 3, // 3日間
+ 'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
+ );
// ユニークカウント用
// TODO: Bloom Filter を使うようにしても良さそう
redisPipeline.sadd(`hashtagUsers:${hashtag}`, userId);
+ redisPipeline.expire(`hashtagUsers:${hashtag}`,
+ 60 * 60, // 1時間
+ 'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
+ );
- await redisPipeline.exec();
-
- const TTL = await this.redisClient.ttl(`hashtagUsers:${hashtag}`);
-
- if (TTL === -1) {
- this.redisClient.expire(`hashtagUsers:${hashtag}`,
- 60 * 60, // 1時間
- //'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
- );
- }
-
- const TTLwindow = await this.redisClient.ttl(`hashtagUsers:${hashtag}:${window}`);
-
- if (TTLwindow === -1) {
- this.redisClient.expire(`hashtagUsers:${hashtag}:${window}`,
- 60 * 60 * 24 * 3, // 3日間
- //'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
- );
- }
+ redisPipeline.exec();
}
@bindThis