Persist your objects to Cassandra -- conforms to ActiveModel API
Note: If you haven't already, make sure you have Cassandra configured and running. Here are a few resources to get you started:
- Cassandra Apache Project
- Cassandra Wiki
- Evan Weaver's "Up and Running with Cassandra"
- There is a sample
storage-conf.xml
for this example at example/storage-conf.xml.
You must configure CassandraModel with your keyspace and hosts:
CassandraModel.config(:keyspace => "MyApp", :hosts => "127.0.0.1:9160")
class User
include CassandraModel::Resource
column :email
column :name
end
@user = User.new(:email => '[email protected]', :name => "Brian Smith")
@user.save
puts "Key: #{@user.key}" # Note that a key will be auto-generated (GUID) if none is given
@user = User.get("11cb871a-338b-11df-9f62-ef46bcab0d62")
puts "#{@user.email} / #{@user.name}"
Copyright (c) 2010 Brian Smith. See LICENSE for details.