|
|
@ -11,7 +11,7 @@ DOCUMENTATION = '''
|
|
|
|
- This cache uses JSON formatted, per host records saved in Redis.
|
|
|
|
- This cache uses JSON formatted, per host records saved in Redis.
|
|
|
|
version_added: "1.9"
|
|
|
|
version_added: "1.9"
|
|
|
|
requirements:
|
|
|
|
requirements:
|
|
|
|
- redis (python lib)
|
|
|
|
- redis>=2.4.5 (python lib)
|
|
|
|
options:
|
|
|
|
options:
|
|
|
|
_uri:
|
|
|
|
_uri:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
@ -48,9 +48,9 @@ from ansible.errors import AnsibleError
|
|
|
|
from ansible.plugins.cache import BaseCacheModule
|
|
|
|
from ansible.plugins.cache import BaseCacheModule
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from redis import StrictRedis
|
|
|
|
from redis import StrictRedis, VERSION
|
|
|
|
except ImportError:
|
|
|
|
except ImportError:
|
|
|
|
raise AnsibleError("The 'redis' python module is required for the redis fact cache, 'pip install redis'")
|
|
|
|
raise AnsibleError("The 'redis' python module (version 2.4.5 or newer) is required for the redis fact cache, 'pip install redis'")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CacheModule(BaseCacheModule):
|
|
|
|
class CacheModule(BaseCacheModule):
|
|
|
@ -99,7 +99,10 @@ class CacheModule(BaseCacheModule):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self._db.set(self._make_key(key), value2)
|
|
|
|
self._db.set(self._make_key(key), value2)
|
|
|
|
|
|
|
|
|
|
|
|
self._db.zadd(self._keys_set, time.time(), key)
|
|
|
|
if VERSION[0] == 2:
|
|
|
|
|
|
|
|
self._db.zadd(self._keys_set, time.time(), key)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self._db.zadd(self._keys_set, {key: time.time()})
|
|
|
|
self._cache[key] = value
|
|
|
|
self._cache[key] = value
|
|
|
|
|
|
|
|
|
|
|
|
def _expire_keys(self):
|
|
|
|
def _expire_keys(self):
|
|
|
|