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

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

Open
slyphon opened this issue May 9, 2012 · 0 comments
Open

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

slyphon opened this issue May 9, 2012 · 0 comments
Assignees

Comments

@slyphon
Copy link
Contributor

slyphon commented May 9, 2012

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

@ghost ghost assigned slyphon May 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant