def delete(self, key):
     try:
         self._rlock.acquire()
         opaque, cas, data = self.memcached(key).delete(key)
         if self.store_enabled:
             self.kv_store.delete(key)
         self._rlock.release()
         if cas == 0:
             raise MemcachedError(7, "Invalid cas value")
     except Exception as e:
         self._rlock.release()
         raise MemcachedError(7, e.message)
Example #2
0
    def set(self, key, value, ttl=-1, collection=None):
        self._rlock.acquire()
        try:
            if ttl >= 0:
                self.memcached(key).set(key, ttl, 0, value)
            else:
                self.memcached(key).set(key, 0, 0, value)

            if self.store_enabled:
                self.kv_store.write(key, hashlib.md5(value).digest(), ttl)
        except MemcachedError as e:
            self._rlock.release()
            raise MemcachedError(e.status, e.msg)
        except AssertionError:
            self._rlock.release()
            raise AssertionError
        except:
            self._rlock.release()
            raise Exception("General Exception from KVStoreAwareSmartClient.set()")

        self._rlock.release()