Skip to content

Instantly share code, notes, and snippets.

@hiroeorz
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroeorz/22ceb81ea5d25161708d to your computer and use it in GitHub Desktop.
Save hiroeorz/22ceb81ea5d25161708d to your computer and use it in GitHub Desktop.
$ riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
maps created
$ riak-admin bucket-type create sets '{"props":{"datatype":"set"}}'
sets created
$ riak-admin bucket-type create counters '{"props":{"datatype":"counter"}}'
counters created
$ riak-admin bucket-typs <bucket名>
$ curl http://localhost:8097/types/counters/buckets/counters/datatypes/traffic_tickets
{"type":"counter","value":11}
$ bundle exec irb
$ riak-admin bucket-type activate maps
maps has been activated
$ riak-admin bucket-type activate sets
sets has been activated
$ riak-admin bucket-type activate counters
counters has been activated
$ git clone https://github.com/basho/riak-ruby-client.git
$ cd riak-ruby-client
$ bundle install --path vendor/bundle
$ bundle exec irb
>
$ curl http://localhost:8098/types/counters/buckets/counters/datatypes/traffic_tickets
{"type":"counter","value":1}
mike.registers["name"] #=> "mike"
mike.registers["age"] #=> "3"
mike.flags["male"] #=> false
mike.counters["nya-"].value #=> 1
require "riak"
client = Riak::Client.new(nodes:[{:host => "127.0.0.1", :pb_port => 8087}])
bucket = client.bucket("counters")
counter = Riak::Crdt::Counter.new(bucket, 'traffic_tickets', 'counters')
counter.value #=> 11
# irb1側からインクリメント
counter.increment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment