diff --git a/README b/README index afbfa40..4261739 100644 --- a/README +++ b/README @@ -23,33 +23,41 @@ Connect to a server: Create, set and read nodes: - z.create("/bacon", "text to be stored in the new node", 0) - data, stat = z.get("/bacon") - # => ["text to be stored in the new node"...] + z.create(:path => "/bacon", :data => "text to be stored in the new node") + => {:req_id=>1, :rc=>0, :path=>"/bacon"} + + data = z.get(:path => "/bacon") + => {:req_id=>2, :rc=>0, :data=>"text to be stored in the new node", :stat=>#} - z.set("/bacon", "an entirely different line of text", stat.version) - z.set("/bacon", "this won't work", stat.version) + z.set(:path => "/bacon", :text => "an entirely different line of text", data[:stat].version) + + z.set(:path => "/bacon", :text => "this won't work", data[:stat].version) # CZookeeper::BadVersionError: expected version does not match actual version + => {:req_id=>17, :rc=>-103, :stat=>#} - data, stat = z.get("/bacon") - # => ["an entirely different line of text"...] - z.delete("/bacon", stat.version) + data = z.get(:path => "/bacon") + + z.delete(:path => "/bacon", :version => data[:stat].version) Create ephemeral and sequence nodes: - z.create("/parent", "parent node", 0) + z.create(:path => "/parent", :data => "parent node") - z.create("/parent/test-", - "an ordered ephemeral node", - Zookeeper::EPHEMERAL | Zookeeper::SEQUENCE) + z.create(:path => "/parent/test-", + :data => "an ordered ephemeral node", + :ephemeral => true, + :sequence => true) # => "/parent/test-0" - z.create("/parent/test-", - "an ordered ephemeral node", - Zookeeper::EPHEMERAL | Zookeeper::SEQUENCE) + z.create(:path => "/parent/test-", + :data => "an ordered ephemeral node", + :ephemeral => true, + :sequence => true) # => "/parent/test-1" - z.get_children(:path => "/") + z.get_children(:path => "/parent") + + => {:req_id=>31, :rc=>0, :children=>["test-0000000000", "test-0000000001"], :stat=>#} == Idioms