mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-14 10:05:46 +01:00
upd: move TTL after pipeline execution
This commit is contained in:
parent
4fbd9dcfbf
commit
61c66b3825
1 changed files with 11 additions and 11 deletions
|
@ -177,29 +177,29 @@ export class HashtagService {
|
||||||
// チャート用
|
// チャート用
|
||||||
redisPipeline.pfadd(`hashtagUsers:${hashtag}:${window}`, userId);
|
redisPipeline.pfadd(`hashtagUsers:${hashtag}:${window}`, userId);
|
||||||
|
|
||||||
const TTLwindow = await this.redisClient.ttl(`hashtagUsers:${hashtag}:${window}`);
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
await redisPipeline.exec();
|
||||||
|
|
||||||
const TTL = await this.redisClient.ttl(`hashtagUsers:${hashtag}`);
|
const TTL = await this.redisClient.ttl(`hashtagUsers:${hashtag}`);
|
||||||
|
|
||||||
if (TTL === -1) {
|
if (TTL === -1) {
|
||||||
redisPipeline.expire(`hashtagUsers:${hashtag}`,
|
this.redisClient.expire(`hashtagUsers:${hashtag}`,
|
||||||
60 * 60, // 1時間
|
60 * 60, // 1時間
|
||||||
//'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
|
//'NX', // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
redisPipeline.exec();
|
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" = 有効期限がないときだけ設定
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
Loading…
Reference in a new issue