hi all
I want to use hbase as a global cache. I need some advice .
getFromCache(String key){
get from hbase;
if exist return result;
value="working...";
boolean res=checkAndPut;
if(res){
value=doWork(key);
Put(key, value);
}else{ //some other thread is doing work now
//sleep a while and retry
for(int i=0;i<MAX_RETRY;i++){
sleep;
get value from hbase
if(value!="working...") return value;
}
//some thing wrong happens such as working thread crash
//do it myself
value=doWork(key);
Put(key,value);
return value;
}
}
btw, hbase has TTL for column family. is it possible to set ttl
per row/cell?