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

Support for write with unless_exist: true #183

Closed
mintuhouse opened this issue Jun 30, 2024 · 3 comments · Fixed by #188
Closed

Support for write with unless_exist: true #183

mintuhouse opened this issue Jun 30, 2024 · 3 comments · Fixed by #188

Comments

@mintuhouse
Copy link

I am implementing a simple lock interface on Rails.cache
& currently using Rails.cache.fetch(lock_key, expires_in: timeout) { lock_value } == lock_value
But it is not atomic as it makes multiple SQL queries

Can we implement support for Rails.cache.write(lock_key, lock_value, unless_exist: true, expires_in: timeout)

@djmb
Copy link
Collaborator

djmb commented Jul 22, 2024

Should be fixed by #188, but that will have to wait for support for Rails 7.1 and earlier to be dropped.

@skatkov
Copy link
Contributor

skatkov commented Jul 22, 2024

@djmb can we have two side-by-side?

In case Rails 7.1 unless_exist version will be used, if version is older it will use different class.

@djmb
Copy link
Collaborator

djmb commented Jul 23, 2024

@skatkov - I've had to rework the PR to handle expired entries, which had the side effect of removing the dependency on Rails 7.2+ so we'll be able to merge that now.

@djmb djmb closed this as completed in #188 Jul 23, 2024
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 a pull request may close this issue.

3 participants