Git Product home page Git Product logo

cassandra's Introduction

cassandra

A Ruby client for the Cassandra distributed database.

License

Copyright 2009, 2010 Twitter, Inc. See included LICENSE file. Portions copyright 2004-2009 David Heinemeier Hansson, and used with permission.

Features

  • clean encapsulation of the Thrift API

  • compatible UUID and Long classes, for GUID generation

  • Ruby 1.9 compatibility

The Github source repository is here. Patches and contributions are very welcome.

Installation

You need Ruby 1.8 or 1.9. If you have those, just run:

sudo gem install cassandra

Cassandra itself is a rapidly moving target. In order to get a working server, use the ‘bin/cassandra_helper` script:

cassandra_helper cassandra

A server will be installed in ‘$HOME/cassandra/server`, and started in debug mode.

WARNING: Don’t use the test folder for your data, as it will get overwritten when you update the gem.

Usage

Now, start IRb and require the library, which defaults to version 0.6 of the Cassandra API:

require 'cassandra'

Alternatively, you can specify a version of the Cassandra API to use:

require 'cassandra/0.6'

or

require 'cassandra/0.7'

Connect to a server and keyspace:

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

Login on server if the keyspace require authentication:

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

Insert into a column family. You can insert a ‘Cassandra::OrderedHash`, or a regular Hash, if order doesn’t matter:

client.insert(:Users, "5", {'screen_name' => "buttonscat"})

Insert into a super column family:

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

Query a super column:

timeline = client.get(:UserRelationships, "5", "user_timeline")

The returned result will always be a Cassandra::OrderedHash.

See Cassandra for more methods.

Configuration

By default, cassandra is setup to listen on localhost. If you want to move your clients to another host, you’re going to need to change which interface it binds to in the storage-conf.xml. You should also change the seed address.

Node Auto-Discovery

The list of hosts you pass to the client is only used to auto-discover all the nodes in your cluster. You don’t need to give the client a list of all of your nodes.

Further reading

Reporting problems

The Github issue tracker is here. If you have problems with this library or Cassandra itself, please use the cassandra-user mailing list.

cassandra's People

Contributors

aanand avatar b avatar bierbaum avatar careo avatar edmond avatar grantr avatar gregory-m avatar guilleiguaran avatar jamesgolick avatar jmhodges avatar mperham avatar nzkoz avatar ryanking avatar subelsky avatar tritonrc avatar trydionel avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.