cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dir dir <sikerasa...@gmail.com>
Subject Re: Cassandra Java Client
Date Sat, 17 Apr 2010 07:27:54 GMT
What is a SpyMemCahced??
What is the correlation between SpyMemCahced and Cassandra??
Thank You.

Dir.

On Sat, Apr 17, 2010 at 3:10 AM, Weijun Li <weijunli@gmail.com> wrote:

> I'm using spymemcached and it works great! Easy to use, support sharding
> and compression and can handle high volume traffic.
>
> http://code.google.com/p/spymemcached/
>
> -Weijun
>
>
> On Fri, Apr 16, 2010 at 3:29 AM, Linton N <gabrialmarialinton@gmail.com>wrote:
>
>> import java.util.List;
>> import java.io.UnsupportedEncodingException;
>>
>> import org.apache.thrift.transport.TTransport;
>>
>> import org.apache.thrift.transport.TSocket;
>> import org.apache.thrift.protocol.TProtocol;
>> import org.apache.thrift.protocol.TBinaryProtocol;
>> import org.apache.thrift.TException;
>> import org.apache.cassandra.service.*;
>>
>> public class CClient
>> {
>>     public static void main(String[] args)
>>     throws TException, InvalidRequestException, UnavailableException, UnsupportedEncodingException,
NotFoundException
>>
>>     {
>>         TTransport tr = new TSocket("localhost", 9160);
>>
>>         TProtocol proto = new TBinaryProtocol(tr);
>>         Cassandra.Client client = new Cassandra.Client(proto);
>>
>>         tr.open();
>>
>>         String key_user_id = "1";
>>
>>         // insert data
>>         long timestamp = System.currentTimeMillis();
>>
>>         client.insert("Keyspace1",
>>                       key_user_id,
>>                       new ColumnPath("Standard1", null, "name".getBytes("UTF-8")),
>>
>>                       "Chris Goffinet".getBytes("UTF-8"),
>>                       timestamp,
>>                       ConsistencyLevel.ONE);
>>         client.insert("Keyspace1",
>>                       key_user_id,
>>                       new ColumnPath("Standard1", null, "age".getBytes("UTF-8")),
>>
>>                       "24".getBytes("UTF-8"),
>>                       timestamp,
>>                       ConsistencyLevel.ONE);
>>
>>         // read single column
>>         ColumnPath path = new ColumnPath("Standard1", null, "name".getBytes("UTF-8"));
>>
>>         System.out.println(client.get("Keyspace1", key_user_id, path, ConsistencyLevel.ONE));
>>
>>
>>         // read entire row
>>         SlicePredicate predicate = new SlicePredicate(null, new SliceRange(new byte[0],
new byte[0], false, 10));
>>
>>         ColumnParent parent = new ColumnParent("Standard1", null);
>>
>>         List<ColumnOrSuperColumn> results = client.get_slice("Keyspace1", key_user_id,
parent, predicate, ConsistencyLevel.ONE);
>>
>>         for (ColumnOrSuperColumn result : results)
>>         {
>>             Column column = result.column;
>>             System.out.println(new String(column.name, "UTF-8") + " -> " + new
String(column.value, "UTF-8"));
>>
>>         }
>>
>>         tr.close();
>>     }
>> }
>>
>>
>>
>>
>>
>> On Fri, Apr 16, 2010 at 3:26 PM, Nirmala Agadgar <nirmala.ab@gmail.com>wrote:
>>
>>> Hi,
>>>
>>> Can anyone tell how to implement Client that can insert data into
>>> cassandra in Java. Any Code or guidelines would be helpful.
>>>
>>> -
>>> Nirmala
>>>
>>>
>>
>>
>>
>> --
>> --
>> With Love
>>  Lin N
>>
>
>

Mime
View raw message