Skip to content

Instantly share code, notes, and snippets.

@akishin
Created May 18, 2010 15:56
Show Gist options
  • Save akishin/405153 to your computer and use it in GitHub Desktop.
Save akishin/405153 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')
# SuperColumn として name を指定
client.insert(:Super1, 'foo', { 'name' => {'first' => 'bar', 'last' => 'baz'} } )
# SuperColumn はあってもなくても可
client.insert(:Super1, 'foo', { 'age' => '99' } )
# key だけを指定して取得
p client.get(:Super1, 'foo')
# SuperColumn を指定して取得
p client.get(:Super1, 'foo', 'name')
# SuperColumn を指定して get_columns 呼び出し
p client.get_columns(:Super1, 'foo', ['name'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment