コード例 #1
0
ファイル: memorycache.py プロジェクト: OldBlackJoe/synaps
 def set(self, key, value, time=0, min_compress_len=0):
     """Sets the value for a key."""
     timeout = 0
     if time != 0:
         timeout = utils.utcnow_ts() + time
     self.cache[key] = (timeout, value)
     return True
コード例 #2
0
 def set(self, key, value, time=0, min_compress_len=0):
     """Sets the value for a key."""
     timeout = 0
     if time != 0:
         timeout = utils.utcnow_ts() + time
     self.cache[key] = (timeout, value)
     return True
コード例 #3
0
ファイル: memorycache.py プロジェクト: OldBlackJoe/synaps
    def get(self, key):
        """Retrieves the value for a key or None.

        this expunges expired keys during each get"""

        for k in self.cache.keys():
            (timeout, _value) = self.cache[k]
            if timeout and utils.utcnow_ts() >= timeout:
                del self.cache[k]

        return self.cache.get(key, (0, None))[1]
コード例 #4
0
    def get(self, key):
        """Retrieves the value for a key or None.

        this expunges expired keys during each get"""

        for k in self.cache.keys():
            (timeout, _value) = self.cache[k]
            if timeout and utils.utcnow_ts() >= timeout:
                del self.cache[k]

        return self.cache.get(key, (0, None))[1]