Skip to content
/ hector.rb Public
forked from jashmenn/hector.rb

Hector-based Cassandra client for JRuby

Notifications You must be signed in to change notification settings

cosm/hector.rb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hector.rb

A Cassandra client for JRuby, backed by Hector.

Usage

cluster = Hector.cluster("Hector", "127.0.0.1:9160")
ks_name = java.util.UUID.randomUUID.to_s.gsub("-","")
client = Hector.new(nil, @cluster, :retries => 2, :exception_classes => [])
column_families = [{:name =>"a"}, {:name => "b", :type => :super}]
client.add_keyspace({:name => ks_name, :strategy => :local, :replication => 1, :column_families => column_families}) 
client.keyspace = ks_name

sopts = {:n_serializer => :string, :v_serializer => :string, :s_serializer => :string}
client.put_row("a", "row-key", {"k" => "v"})
client.get_rows("a", ["row-key"], sopts) # => {"row-key" => {'k' => 'v'}}
client.get_columns("a", "row-key", ["k"], sopts) # => {'k' => 'v'}


client.put_row("b", "row-key", 
               { "SuperCol"  => {"k" => "v", "k2" => "v2"},
                 "SuperCol2" => {"k" => "v", "k2" => "v2"} })
client.get_super_columns("b", "row-key", "SuperCol", ["k2"], sopts) # => {"k2" => "v2"}

For more examples, see the tests.

History

hector.rb started as a fork of the cassandra gem. However the API is now similar to clj-hector.

We may make this gem API compatible with the cassandra gem in the future.

References

Author

Nate Murray [email protected] http://www.xcombinator.com

About

Hector-based Cassandra client for JRuby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%