Skip to content

Instantly share code, notes, and snippets.

@l1x
Created February 20, 2014 06:00
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 l1x/9107811 to your computer and use it in GitHub Desktop.
Save l1x/9107811 to your computer and use it in GitHub Desktop.
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