Thursday, August 4, 2011

Voldemort Database Integration

Voldemort is very useful, and fast key value database. you can download voldemort from here .

Example:

package voldemort.examples;

import voldemort.client.ClientConfig;
import voldemort.client.SocketStoreClientFactory;
import voldemort.client.StoreClient;
import voldemort.client.StoreClientFactory;
import voldemort.versioning.Versioned;

public class ClientExample {

public static void main(String[] args) {

// In real life this stuff would get wired in
String bootstrapUrl = "tcp://localhost:6666";
StoreClientFactory factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootstrapUrl));

StoreClient client = factory.getStoreClient("my_store_name");

// get the value
Versioned version = client.get("some_key");

// modify the value
version.setObject("new_value");

// update the value
client.put("some_key", version);
}

}

really easy isn't it? confuse? let's discuss it here.

No comments: