Created
November 25, 2009 14:22
-
-
Save pablete/242734 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 './cassandra' | |
require './cassandra_constants' | |
require './cassandra_types' | |
require 'pp' | |
transport = Thrift::BufferedTransport.new(Thrift::Socket.new("localhost", "9160")) | |
transport.open | |
client = CassandraThrift::Cassandra::Client.new(Thrift::BinaryProtocol.new(transport)) | |
keyspace = "Keyspace1" | |
key = "dude_login" | |
columnPath = CassandraThrift::ColumnPath.new(:column_family => "Standard1", :column => "email") | |
value = "[email protected]" | |
t = Time.now | |
timestamp = t.to_i * 1_000_000 + t.usec | |
client.insert(keyspace, key ,columnPath, value, timestamp, CassandraThrift::ConsistencyLevel::ZERO) | |
begin | |
pp client.get(keyspace, key, columnPath, CassandraThrift::ConsistencyLevel::ONE) | |
rescue CassandraThrift::NotFoundException => e | |
puts "Key not found." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment