mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix redis cache for python3
According to the redis-py docs, zrank will return the 0 based index for the value in the sorted set. So the logic here wasn't right to begin with (It just means that a value at the 0-th position would never show up as cached). Need to compare against None to know if the value exists in the cache. https://redis-py.readthedocs.io/en/latest/#redis.StrictRedis.zrank Fixes #25590
This commit is contained in:
parent
498aea8acc
commit
90b1d780eb
1 changed files with 1 additions and 1 deletions
2
lib/ansible/plugins/cache/redis.py
vendored
2
lib/ansible/plugins/cache/redis.py
vendored
|
@ -84,7 +84,7 @@ class CacheModule(BaseCacheModule):
|
||||||
|
|
||||||
def contains(self, key):
|
def contains(self, key):
|
||||||
self._expire_keys()
|
self._expire_keys()
|
||||||
return (self._cache.zrank(self._keys_set, key) >= 0)
|
return (self._cache.zrank(self._keys_set, key) is not None)
|
||||||
|
|
||||||
def delete(self, key):
|
def delete(self, key):
|
||||||
self._cache.delete(self._make_key(key))
|
self._cache.delete(self._make_key(key))
|
||||||
|
|
Loading…
Reference in a new issue