Last active
August 29, 2015 14:06
-
-
Save hiroeorz/22ceb81ea5d25161708d to your computer and use it in GitHub Desktop.
Riak2.0のData Types ref: http://qiita.com/hiroeorz@github/items/c4b162c6a013cfc3e108
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ riak-admin bucket-typs <bucket名> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl http://localhost:8097/types/counters/buckets/counters/datatypes/traffic_tickets | |
{"type":"counter","value":11} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle exec irb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ riak-admin bucket-type activate maps | |
maps has been activated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ riak-admin bucket-type activate sets | |
sets has been activated | |
$ riak-admin bucket-type activate counters | |
counters has been activated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone https://github.com/basho/riak-ruby-client.git | |
$ cd riak-ruby-client | |
$ bundle install --path vendor/bundle | |
$ bundle exec irb | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl http://localhost:8098/types/counters/buckets/counters/datatypes/traffic_tickets | |
{"type":"counter","value":1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mike.registers["name"] #=> "mike" | |
mike.registers["age"] #=> "3" | |
mike.flags["male"] #=> false | |
mike.counters["nya-"].value #=> 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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