First page Back Continue Last page Image

Riak Code Example

https://riak.com/posts/technical/create-your-first-riak-ts-table/index.html?p=13356.html

RiakClient myClient = RiakClient.newClient(myServer);

// Create the key, value and set the bucket

String myKey = Long.toString(System.currentTimeMills());

String myValue = myKey + “:” + Thread.getAllStackTraces().toString();

Location myLocation = new Location(new Namespace(“MyBucket”), myKey);

StoreValue sv = new StoreValue.Builder(myValue).withLocation(myLocation).build();

StoreValue.Response svResponse = myClient.execute(sv);

System.out.println(“response=”+svResponse);

Create a key using current time in milliseconds

Create a Value using current stack trace

Create a Riak Client Interface

Identify Address to Data

Create a Location (Bucket) to receive the Value

Create a StoreValue Object

Execute StoreValue Adding data to the Database

Output Result to standard output