File: cassandra.rb [cassandra-0.23.0 Documentation]

Last Modified
  2015-08-06 11:53:45 +0000
Requires

## Description

Create a new Cassandra client instance. Accepts a keyspace name, and optional host and port.

    client = Cassandra.new('twitter', '127.0.0.1:9160')

If the server requires authentication, you must authenticate before make calls

    client.login!('username','password')

You can then make calls to the server via the `client` instance.

    client.insert(:UserRelationships, "5", {"user_timeline" => {SimpleUUID::UUID.new => "1"}})
    client.get(:UserRelationships, "5", "user_timeline")

For read methods, valid option parameters are:

`:count` | How many results to return. Defaults to 100.
`:start` | Column name token at which to start iterating, inclusive. Defaults to nil, which means the first column in the collation order.
`:finish` | Column name token at which to stop iterating, inclusive. Defaults to nil, which means no boundary.
`:reversed` | Swap the direction of the collation order.
`:consistency` | The consistency level of the request. Defaults to `Cassandra::Consistency::ONE` (one node must respond). Other valid options are `Cassandra::Consistency::ZERO`, `Cassandra::Consistency::QUORUM`, and `Cassandra::Consistency::ALL`.

Note that some read options have no relevance in some contexts.

For write methods, valid option parameters are:

`:timestamp` | The transaction timestamp. Defaults to the current time in milliseconds. This is used for conflict resolution by the server; you normally never need to change it.
`:consistency` | See above.

For the initial client instantiation, you may also pass in <tt>:thrift_client<tt> with a ThriftClient subclass attached. On connection, that class will be used instead of the default ThriftClient class, allowing you to add additional behavior to the connection (e.g. query logging).