sianla / memcached

Automatically exported from code.google.com/p/memcached
0 stars 0 forks source link

version checked supported for get/gets operation (suggestion) #308

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
There is a local cached in my application, and I use memcached as remote 
cached. Does memcached support the feature like that ?

//Application code:
Object get(Object key){
   CASValue local = localCached.get(key);
   if(local != null) {
      //remote.data was not transfered if local & remote have the same version
      //for reducing network traffic & enhancing performance
      CASValue remote = remoteCached.get(key, local.getVersion());
      if(remote.getVersion() == local.getVersion())
         return local.getData();
      else {
         localCached.set(key, remote);
         return remote.getData();
      }
   }
   else
   {
      CASValue remote = remoteCached.get(key);
      localCached.set(key, remote);
      return remote.getData();
   }
}

Original issue reported on code.google.com by tim.wong...@gmail.com on 1 Feb 2013 at 3:47

GoogleCodeExporter commented 8 years ago
Not easily no. You can use a separate key that just contains a version number.

Original comment by dorma...@rydia.net on 9 Dec 2013 at 2:51