I am currently writing an application that requires bulk operations on a key/value store, at this time I am using membase.
spymemcached allows bulk get, but not bulk CAS or add; features that I think would be widely used if implemented.
At this point my code for a set of bulk operations is roughly as shown below.
"client" is a single MemcachedClient.
ArrayList<Future<Boolean>> futures = new ArrayList<Future<Boolean>>();
ArrayList<String> bulkGet = new ArrayList<String>();
for(int i=0; i<50; i++){
String key = "Key_" + x + "_" + i;
Future<Boolean> fut = client.add(key, 0, "Value_" + x + "_" + i);
futures.add(fut);
bulkGet.add(key);
}
int count = 0;
for(Future<Boolean> fut : futures){
if(fut.get()==true){
count++;
}
}
System.out.println("Added " + count + " records.");
Map<String,Object> bulkGot = client.getBulk(bulkGet);
System.out.println("Retrieved " + bulkGot.size() + " records");
The blocking call on Future.get() seems highly inefficient, is there a better way? In my actual scenario I'd like the ability to handle the futures as soon as they return (which may or may not be in the order in which they were sent?).
Also, are the following operations possible (or planning to be implemented)?
-Add or return existing value
-Delete if value equals a known value
-Set if value equals a known value
Thanks, Marcus