Skip to content

Instantly share code, notes, and snippets.

@chikamichi
Created April 17, 2010 22:49
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 chikamichi/369873 to your computer and use it in GitHub Desktop.
Save chikamichi/369873 to your computer and use it in GitHub Desktop.
Notes on using Cassandra latest release with the Ruby binding

Install

gem install cassandra
gem install simple_uuid

Run test plateform

Updated workflow from Up and running with Cassandra.

irb
require 'cassandra'
include Cassandra::Constants

twitter = Cassandra.new('Twitter')

user = {'screen_name' => 'buttonscat'}
twitter.insert(:Users, '5', user)

tweet1 = {'text' => 'Nom nom nom nom nom.', 'user_id' => '5'}
twitter.insert(:Statuses, '1', tweet1)

tweet2 = {'text' => '@evan Zzzz....', 'user_id' => '5', 'reply_to_id' => '8'}
twitter.insert(:Statuses, '2', tweet2)

twitter.insert(:UserRelationships, '5', {'user_timeline' => {SimpleUUID::UUID.new => '1'}})
twitter.insert(:UserRelationships, '5', {'user_timeline' => {SimpleUUID::UUID.new => '2'}})

timeline = twitter.get(:UserRelationships, '5', 'user_timeline', :reversed => true)
timeline.map { |time, id| twitter.get(:Statuses, id, 'text') }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment