Skip to content

Instantly share code, notes, and snippets.

@cchandler
Created October 12, 2009 03:40
Show Gist options
  • Save cchandler/208103 to your computer and use it in GitHub Desktop.
Save cchandler/208103 to your computer and use it in GitHub Desktop.
require './cassandra'
require './cassandra_constants'
require './cassandra_types'
transport = Thrift::BufferedTransport.new(Thrift::Socket.new("127.0.0.1", "9160"))
transport.open
client = CassandraThrift::Cassandra::Client.new(Thrift::BinaryProtocol.new(transport))
columnPath = CassandraThrift::ColumnPath.new(:column_family => "Places", :column => "test")
#For client-side managed timestamps
t = Time.now
time = t.to_i * 1_000_000 + t.usec
begin
client.insert("KeySpace","moo",columnPath, "test value for key 'moo' ", time,CassandraThrift::ConsistencyLevel::ONE)
p client.get("KeySpace","moo",columnPath,CassandraThrift::ConsistencyLevel::ONE)
rescue CassandraThrift::NotFoundException => e
p "No value"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment