hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Li Li <fancye...@gmail.com>
Subject use hbase as a global cache
Date Mon, 14 Apr 2014 06:06:39 GMT
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?

Mime
View raw message