Skip to content

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 force-pushed the fix-cluster-cas-pattern branch from f03b7a0 to 30da9c4 Compare April 28, 2024 00:53
@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
@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