コード例 #1
0
ファイル: memory.py プロジェクト: DorChen/tacker
    def _set(self, key, value, ttl=0, not_exists=False):
        with lockutils.lock(key):

            # NOTE(flaper87): This is needed just in `set`
            # calls, hence it's not in `_set_unlocked`
            if not_exists and self._exists_unlocked(key):
                return False

            self._set_unlocked(key, value, ttl)
            return True
コード例 #2
0
    def _set(self, key, value, ttl=0, not_exists=False):
        with lockutils.lock(key):

            # NOTE(flaper87): This is needed just in `set`
            # calls, hence it's not in `_set_unlocked`
            if not_exists and self._exists_unlocked(key):
                return False

            self._set_unlocked(key, value, ttl)
            return True
コード例 #3
0
ファイル: memory.py プロジェクト: DorChen/tacker
    def _incr_append(self, key, other):
        with lockutils.lock(key):
            timeout, value = self._get_unlocked(key)

            if value is None:
                return None

            ttl = timeutils.utcnow_ts() - timeout
            new_value = value + other
            self._set_unlocked(key, new_value, ttl)
            return new_value
コード例 #4
0
    def _incr_append(self, key, other):
        with lockutils.lock(key):
            timeout, value = self._get_unlocked(key)

            if value is None:
                return None

            ttl = timeutils.utcnow_ts() - timeout
            new_value = value + other
            self._set_unlocked(key, new_value, ttl)
            return new_value
コード例 #5
0
ファイル: lockutils.py プロジェクト: paperandsoap/tacker
 def __init__(self, name, lock_file_prefix=None):
     self.mgr = lockutils.lock(name, lock_file_prefix, True)
コード例 #6
0
ファイル: memory.py プロジェクト: DorChen/tacker
 def __contains__(self, key):
     with lockutils.lock(key):
         return self._exists_unlocked(key)
コード例 #7
0
ファイル: memory.py プロジェクト: DorChen/tacker
 def _get(self, key, default=None):
     with lockutils.lock(key):
         return self._get_unlocked(key, default)[1]
コード例 #8
0
 def __contains__(self, key):
     with lockutils.lock(key):
         return self._exists_unlocked(key)
コード例 #9
0
 def _get(self, key, default=None):
     with lockutils.lock(key):
         return self._get_unlocked(key, default)[1]