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

ensure lock is held while setting cache #5

Open
n1ywb opened this issue Jun 12, 2019 · 2 comments
Open

ensure lock is held while setting cache #5

n1ywb opened this issue Jun 12, 2019 · 2 comments

Comments

@n1ywb
Copy link
Contributor

n1ywb commented Jun 12, 2019

let v = await this._cache.set(key, this._cacheSetTransform(value), {

If you needed a really strong guarantee that the lock was in fact held while setting a redis cache value and the lock and cache redis servers were one and the same then you could use Lua to query the lock and set the cache value atomically.

I suppose at that point you may as well just store the lock and cache values under the same key

@emk
Copy link
Contributor

emk commented Aug 12, 2020

I believe that this is ruled out by the desire to support separate lock and cache servers in normal operation.

@n1ywb
Copy link
Contributor Author

n1ywb commented Aug 13, 2020

If that's the case then it should probably use distributed transactions to ensure consistency.

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

No branches or pull requests

2 participants