Skip to content

Instantly share code, notes, and snippets.

@akishin
Created May 17, 2010 06:08
Show Gist options
  • Save akishin/403456 to your computer and use it in GitHub Desktop.
Save akishin/403456 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'cassandra'
include Cassandra::Constants
client = Cassandra.new('Keyspace1', '127.0.0.1:9160')
client.batch do
client.insert(:Standard1, '001', { 'first' => 'shin', 'last' => 'akiyama', 'age' => '31' })
client.insert(:Standard1, '002', { 'first' => 'foo', 'last' => 'bar', 'age' => '20' })
client.insert(:Standard1, '003', { 'first' => 'hoge', 'last' => 'fuga', 'age' => '15' })
end
# 追加したデータを取得してみる
client.get_range(:Standard1).each { |obj|
p "Key : #{obj.key}"
obj.columns.each { |col|
p col
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment