Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

implement compare-and-swap (check-and-set, whatevs) #29

Open
slyphon opened this Issue · 0 comments

1 participant

@slyphon
Owner

for the concurrency-enthusiasts

set('/foo/bar', 'the new data', :check => 'the current data')

# which would do

data, stat = zk.get('/foo/bar')

if data == opts[:check]
  zk.set('/foo/bar', 'the new data', :version => stat.version)  
else
  raise CheckAndSetAssertionFailed, "You think it's '#{opts[:check]}' but it's '#{data}'"
  # yes, that's a reference to The Wire
end

with some number of :retries perhaps

@slyphon slyphon was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.