Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redlock service #182

Merged
merged 7 commits into from
Nov 14, 2023
Merged

Redlock service #182

merged 7 commits into from
Nov 14, 2023

Conversation

tanghel
Copy link
Contributor

@tanghel tanghel commented Nov 14, 2023

No description provided.

}

private async lockOnce(key: string, keyExpiration: number): Promise<boolean> {
const result = await this.redis.setnx(key, '1');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SETNX is deprecated. You can use SET with the NX option

private async lockOnce(key: string, keyExpiration: number): Promise<boolean> {
const result = await this.redis.setnx(key, '1');
if (result === 1) {
await this.redis.pexpire(key, keyExpiration);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use SET, you can provide an expiration time and there is no need to make another call to redis

@tanghel tanghel merged commit 22e223a into 1.3.0 Nov 14, 2023
2 checks passed
@tanghel tanghel deleted the redlock-service branch November 14, 2023 13:41
tanghel added a commit that referenced this pull request Nov 14, 2023
* redlock basic functionality

* renamed metric correctly

* set acquired duration also when not timing out

* added redlock folder in index

* extend ttl concept, improved logging

* log level, other refactorings

* use single set function with expiry integrated
tanghel added a commit that referenced this pull request Nov 20, 2023
* redlock basic functionality

* renamed metric correctly

* set acquired duration also when not timing out

* added redlock folder in index

* extend ttl concept, improved logging

* log level, other refactorings

* use single set function with expiry integrated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants