-
Notifications
You must be signed in to change notification settings - Fork 66
Getting Started
posulliv edited this page Feb 21, 2011
·
1 revision
libcassandra is a simple C++ client for Cassandra that wraps the lower level thrift code.
#include <libcassandra/cassandra_factory.h>
#include <libcassandra/cassandra.h>
CassandraFactory factory("localhost", 9160);
tr1::shared_ptr<Cassandra> client(factory.create());
#include <libcassandra/keyspace_definition.h>
KeyspaceDefinition ks_def;
ks_def.setName("my_ks");
client->createKeyspace();
client->setKeyspace(ks_def.getName());
client->login("my_username", "my_password");
#include <libcassandra/column_family_definition.h>
ColumnFamilyDefinition cf_def;
cf_def.setName("my_cf");
cf_def.setKeyspaceName(ks_def.getName());
client->createColumnFamily(cf_def);
client->insertColumn("my_key", cf_def.getName(), "my_col_name", "my_col_data");
string res = client->getColumnValue("my_key", cf_def.getName(), "my_col_name");