summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2016-09-14 13:27:42 -0400
committerBrian Coca <bcoca@users.noreply.github.com>2016-09-14 13:27:42 -0400
commitc633022fcafaf7ec2c678398cf9f696ca70053ad (patch)
tree86825c83daf71c2e262a53d5a598c8c257f7d17b
parent9785e064c13f2acec02ed45b3a7cc66876a96339 (diff)
downloadansible-c633022fcafaf7ec2c678398cf9f696ca70053ad.tar.gz
[wip] Let jsonfile and memcached cache plugins understand fact_caching_timeout=0 (#17565)
* Add support for no-expiration to jsonfile cache * Let memcached cache use fact_caching_timeout=0 If fact_cache=memcached and fact_caching_timeout=0 memcached would hit a NameError on _expire_keys
-rw-r--r--lib/ansible/plugins/cache/jsonfile.py3
-rw-r--r--lib/ansible/plugins/cache/memcached.py2
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py
index f2f42f3cc2..f13443d871 100644
--- a/lib/ansible/plugins/cache/jsonfile.py
+++ b/lib/ansible/plugins/cache/jsonfile.py
@@ -108,6 +108,9 @@ class CacheModule(BaseCacheModule):
def has_expired(self, key):
+ if self._timeout == 0:
+ return False
+
cachefile = "%s/%s" % (self._cache_dir, key)
try:
st = os.stat(cachefile)
diff --git a/lib/ansible/plugins/cache/memcached.py b/lib/ansible/plugins/cache/memcached.py
index 01fbefb07b..80a42a5b21 100644
--- a/lib/ansible/plugins/cache/memcached.py
+++ b/lib/ansible/plugins/cache/memcached.py
@@ -157,7 +157,7 @@ class CacheModule(BaseCacheModule):
def _expire_keys(self):
if self._timeout > 0:
expiry_age = time.time() - self._timeout
- self._keys.remove_by_timerange(0, expiry_age)
+ self._keys.remove_by_timerange(0, expiry_age)
def get(self, key):
value = self._cache.get(self._make_key(key))