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

Fix a cluster client interface for CAS operations to be more compatible with standalone client #1270

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

supercaracal
Copy link
Contributor

@supercaracal supercaracal commented Apr 28, 2024

Sorry the implementation changed again and again. I recently fixed the optimistic locking feature (a.k.a CAS operation), But I've considered a better implementation for the feature in the cluster client. I haven't convinced the previous implementation at a point that users incur to use two receivers depending on the use case. So this pull request makes receivers consolidated.

Before

redis.watch("{my}key") do |client|
  if redis.get("{my}key") == "some value" # <= this receiver
    client.multi do |tx|
      tx.set("{my}key", "other value")
      tx.incr("{my}counter")
    end
  else
    client.unwatch
  end
end

After

redis.watch("{my}key") do |client|
  if client.get("{my}key") == "some value" # <= this receiver
    client.multi do |tx|
      tx.set("{my}key", "other value")
      tx.incr("{my}counter")
    end
  else
    client.unwatch
  end
end

@supercaracal supercaracal marked this pull request as ready for review April 28, 2024 01:12
@byroot byroot merged commit c4e6dcc into redis:master Apr 29, 2024
15 of 17 checks passed
@supercaracal supercaracal deleted the fix-cluster-cas-pattern branch April 29, 2024 11:31
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