Created
February 20, 2014 06:00
-
-
Save l1x/9107811 to your computer and use it in GitHub Desktop.
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' | |
require 'pp' | |
require 'uuid' | |
Riak.disable_list_keys_warnings = true | |
# Automatically balance between multiple nodes | |
client = Riak::Client.new( | |
:protocol => "pbc", | |
:nodes => [ | |
{:host => '1.1.1.1', :pb_port => 1111}, | |
{:host => '2.2.2.2', :pb_port => 1111}, | |
{:host => '3.3.3.3', :pb_port => 1111} | |
] | |
) | |
#lets create a 1000 keys (=APIs) in | |
bucket = client.bucket("BUCKET-NAME") | |
@uuid = UUID.new | |
(1..1000).each { | |
my_uuid=@uuid.generate | |
pp my_uuid | |
new_one = Riak::RObject.new(bucket, my_uuid) | |
new_one.content_type = "application/json" # You must set the content type. | |
new_one.raw_data = File.read("test.json") | |
new_one.store | |
} | |
#END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment