Skip to content

Commit 5bacc23

Browse files
committed
revert code
1 parent 9056eba commit 5bacc23

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/cache/RateLimitCache.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ export async function checkAndUpdateRateLimit(opts: CheckAndUpdateRateLimitOptio
2929

3030
const [res, ttl] = (await mainMulti.exec()) as [RateLimitCache, number];
3131

32-
if (ttl === -1) {
33-
console.error(`Rate limit key has no TTL: key=${key} res=${JSON.stringify(res)}`);
34-
return false;
35-
}
32+
// if (ttl === -1) {
33+
// console.error(`Rate limit key has no TTL: key=${key} res=${JSON.stringify(res)}`);
34+
// return false;
35+
// }
3636

3737
if (!res || Object.keys(res).length === 0) {
3838
const multi = redisClient.multi();
39-
multi.hSetNX(key, 'requests', '1');
40-
41-
multi.pExpire(key, opts.perMS, 'NX');
39+
multi.hSet(key, {
40+
requests: 1,
41+
});
42+
multi.pExpire(key, opts.perMS);
4243
await multi.exec();
4344
return false as const;
4445
}
@@ -69,7 +70,7 @@ export async function checkAndUpdateRateLimit(opts: CheckAndUpdateRateLimitOptio
6970
multi.hSet(key, {
7071
status: RateLimitStatus.REACHED,
7172
});
72-
multi.pExpire(key, opts.restrictMS, 'NX');
73+
multi.pExpire(key, opts.restrictMS);
7374
await multi.exec();
7475
return ttl;
7576
}

0 commit comments

Comments
 (0)