NAME

Cassandra::Lite - Simple way to access Cassandra 0.7

VERSION

version 0.0.4

DESCRIPTION

This module will offer you a simple way to access Cassandra 0.7 (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 it (timestamp is optional)
$c->insert($columnFamily, $key, {title => 'testing title', body => '...'}, {timestamp => time});

# 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'});

# Remove it
$c->remove($columnFamily, $key, {timestamp => time});       # You can specify timestamp (optional) and consistency_level (optional)

# Change keyspace
$c->keyspace('BlogArticleComment');

# Get count
my $num1 = $c->get_count('Foo', 'key1');
my $num2 = $c->get_count('Foo', 'key2', {consistency_level => 'ALL'});

...

get

get_count

get_slice

insert

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.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 282:

=over should be: '=over' or '=over positive_number'

Around line 287:

You forgot a '=back' before '=head1'