NAME
Cassandra::Lite - Simple way to access Cassandra 0.7/0.8
VERSION
version 0.0.6
DESCRIPTION
This module will offer you a simple way to access Cassandra 0.7/0.8 (maybe later version). Some parts are not same as standard API document (especially arguments order), it's because I want to keep this module easy to use.
You'll need to install Thrift perl modules first to use Cassandra::Lite.
SYNOPSIS
use Cassandra::Lite;
# All supported options:
my $c = Cassandra::Lite->new(
server_name => 'server1', # optional, default to '127.0.0.1'
server_port => 9160, # optional, default to 9160
username => 'username', # optional, default to empty string ''
password => 'xxx', # optional, default to empty string ''
consistency_level_read => 'ONE' # optional, default to 'ONE'
consistency_level_write => 'ONE' # optional, default to 'ONE'
keyspace => 'Keyspace1',
);
# Usually we can use this in dev environment:
my $c = Cassandra::Lite->new(keyspace => 'Keyspace1');
# Now just define $columnFamily and $key
my $columnFamily = 'BlogArticle';
my $key = 'key12345';
# Insert ("insert" is an alias of "put") it. (timestamp is optional)
$c->put($columnFamily, $key, {title => 'testing title', body => '...'}, {timestamp => time}); # OR
$c->insert($columnFamily, $key, {title => 'testing title', body => '...'});
# Get slice
my $res1 = $c->get_slice($columnFamily, $key);
my $res2 = $c->get_slice($columnFamily, $key, {range => ['sliceKeyStart', undef]});
my $res3 = $c->get_slice($columnFamily, $key, {range => [undef, 'sliceKeyFinish']});
my $res4 = $c->get_slice($columnFamily, $key, {range => ['sliceKeyStart', 'sliceKeyFinish']});
# Get a column
my $v1 = $c->get($columnFamily, $key, 'title');
# Higher consistency level
my $v2 = $c->get($columnFamily, $key, 'title', {consistency_level => 'QUORUM'}); # OR
my $v2 = $c->get($columnFamily, $key, 'title', {consistency_level => 'ALL'});
# Remove it ("remove" is an alias of "delete")
$c->delete($columnFamily, $key, {timestamp => time}); # You can specify timestamp (optional) and consistency_level (optional)
$c->remove($columnFamily, $key);
# Change keyspace
$c->keyspace('BlogArticleComment');
# Get count
my $num1 = $c->get_count('Foo', 'key1');
my $num2 = $c->get_count('Foo', 'key2', {consistency_level => 'ALL'});
...
FUNCTION
delete
get
get_count
get_slice
insert
put
remove
SEEALSO
AUTHOR
Gea-Suan Lin, <gslin at gslin.org>
LICENSE AND COPYRIGHT
Copyright 2011 Gea-Suan Lin.
This software is released under 3-clause BSD license. See http://www.opensource.org/licenses/bsd-license.php for more information.