Skip to content

Commit

Permalink
perf: Set lock polling interval to 50ms
Browse files Browse the repository at this point in the history
remove interval increment, increase retry count to 24
  • Loading branch information
adolphnov committed Dec 15, 2024
1 parent 7cfe105 commit ef4e26f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/telegram/handler/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ class Lock {
// if (lock && lock.expiration < Math.floor(Date.now() / 1000)) {
// await ENV.DATABASE.delete(this.lockKey);
// }
while (retry < 5) {
await new Promise(resolve => setTimeout(resolve, 100 * retry));
const lock = await ENV.DATABASE.put(this.lockKey, '1', { expirationTtl: 5, condition: 'NX' });
while (retry < 24) {
await new Promise(resolve => setTimeout(resolve, 50));
const lock = await ENV.DATABASE.put(this.lockKey, '1', { expirationTtl: 1, condition: 'NX' });
if (lock === true || lock === undefined) {
log.info(`Lock success, key: ${this.lockKey}, retry: ${retry}`);
return;
Expand Down

0 comments on commit ef4e26f

Please sign in to comment.