mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
198476e345
commit
cd6d1f9221
4 changed files with 11 additions and 0 deletions
4
lib/ansible/plugins/cache/base.py
vendored
4
lib/ansible/plugins/cache/base.py
vendored
|
@ -26,6 +26,9 @@ from six import add_metaclass
|
||||||
@add_metaclass(ABCMeta)
|
@add_metaclass(ABCMeta)
|
||||||
class BaseCacheModule:
|
class BaseCacheModule:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.__getstate__ = self.copy
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
pass
|
pass
|
||||||
|
@ -53,3 +56,4 @@ class BaseCacheModule:
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def copy(self):
|
def copy(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
2
lib/ansible/plugins/cache/memcached.py
vendored
2
lib/ansible/plugins/cache/memcached.py
vendored
|
@ -113,6 +113,8 @@ class CacheModuleKeys(collections.MutableSet):
|
||||||
self._cache = cache
|
self._cache = cache
|
||||||
self._keyset = dict(*args, **kwargs)
|
self._keyset = dict(*args, **kwargs)
|
||||||
|
|
||||||
|
super(CacheModule, self).__init__()
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
return key in self._keyset
|
return key in self._keyset
|
||||||
|
|
||||||
|
|
2
lib/ansible/plugins/cache/memory.py
vendored
2
lib/ansible/plugins/cache/memory.py
vendored
|
@ -24,6 +24,8 @@ class CacheModule(BaseCacheModule):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
|
|
||||||
|
super(CacheModule, self).__init__()
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
return self._cache.get(key)
|
return self._cache.get(key)
|
||||||
|
|
||||||
|
|
3
lib/ansible/plugins/cache/redis.py
vendored
3
lib/ansible/plugins/cache/redis.py
vendored
|
@ -51,6 +51,8 @@ class CacheModule(BaseCacheModule):
|
||||||
self._cache = StrictRedis(*connection)
|
self._cache = StrictRedis(*connection)
|
||||||
self._keys_set = 'ansible_cache_keys'
|
self._keys_set = 'ansible_cache_keys'
|
||||||
|
|
||||||
|
super(CacheModule, self).__init__()
|
||||||
|
|
||||||
def _make_key(self, key):
|
def _make_key(self, key):
|
||||||
return self._prefix + key
|
return self._prefix + key
|
||||||
|
|
||||||
|
@ -100,3 +102,4 @@ class CacheModule(BaseCacheModule):
|
||||||
for key in self.keys():
|
for key in self.keys():
|
||||||
ret[key] = self.get(key)
|
ret[key] = self.get(key)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue