I was using aspymemcached client to connect to my membase server.
code look like :
public static MemcachedClient MemcachedClient(String bucketName){
URI server1 = new URI("http://192.168.100.111:8091/pools");
URI server2 = new URI("http://127.0.0.1:8091/pools");
ArrayList<URI> serverList = new ArrayList<URI>();
serverList.add(server1);
serverList.add(server2);
return new MemcachedClient(serverList, bucketName, "");
}
For putting object in cache :
public static void makeMembaseCacheEntry(final String key, final int expiryTime, final Object value, final String bucketName) {
MemcachedClient client = getMembaseClient(bucketName);
if (client != null) {
client.set(key, expiryTime, value);
}
For getting object from cache :
public static Object getMembaseCacheEntry(String key) {
Object value = null;
try {
MemcachedClient client = getMembaseClient(bucketName);
if (client != null) {
value = client.get(key);
}
} catch (Exception e) {
}
return value;
}
Now I planning to upgrade membase server to couchbase server, hence I have to use couchbase client java API (Ref : http://docs.couchbase.com/developer/java-2.1/java-intro.html).
In cousebase client all operation performed on JsonObject ref :
http://docs.couchbase.com/developer/java-2.0/documents-basics.html
So how can I migrate above two methods to couchbase client