mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-26 22:03:09 +02:00
upd: make hashtagservice compatible with redis 6.3
This commit is contained in:
parent
a5efe11350
commit
4fbd9dcfbf
1 changed files with 18 additions and 8 deletions
|
@ -176,18 +176,28 @@ export class HashtagService {
|
||||||
|
|
||||||
// チャート用
|
// チャート用
|
||||||
redisPipeline.pfadd(`hashtagUsers:${hashtag}:${window}`, userId);
|
redisPipeline.pfadd(`hashtagUsers:${hashtag}:${window}`, userId);
|
||||||
redisPipeline.expire(`hashtagUsers:${hashtag}:${window}`,
|
|
||||||
60 * 60 * 24 * 3, // 3日間
|
const TTLwindow = await this.redisClient.ttl(`hashtagUsers:${hashtag}:${window}`);
|
||||||
'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
|
|
||||||
);
|
if (TTLwindow === -1) {
|
||||||
|
redisPipeline.expire(`hashtagUsers:${hashtag}:${window}`,
|
||||||
|
60 * 60 * 24 * 3, // 3日間
|
||||||
|
//'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ユニークカウント用
|
// ユニークカウント用
|
||||||
// TODO: Bloom Filter を使うようにしても良さそう
|
// TODO: Bloom Filter を使うようにしても良さそう
|
||||||
redisPipeline.sadd(`hashtagUsers:${hashtag}`, userId);
|
redisPipeline.sadd(`hashtagUsers:${hashtag}`, userId);
|
||||||
redisPipeline.expire(`hashtagUsers:${hashtag}`,
|
|
||||||
60 * 60, // 1時間
|
const TTL = await this.redisClient.ttl(`hashtagUsers:${hashtag}`);
|
||||||
'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
|
|
||||||
);
|
if (TTL === -1) {
|
||||||
|
redisPipeline.expire(`hashtagUsers:${hashtag}`,
|
||||||
|
60 * 60, // 1時間
|
||||||
|
//'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
redisPipeline.exec();
|
redisPipeline.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue