diff --git a/changelogs/fragments/1036-redis-cache-keyset-name.yaml b/changelogs/fragments/1036-redis-cache-keyset-name.yaml new file mode 100644 index 0000000000..bbe34ab6b3 --- /dev/null +++ b/changelogs/fragments/1036-redis-cache-keyset-name.yaml @@ -0,0 +1,3 @@ +minor_changes: + - redis cache plugin - make the redis cache keyset name configurable + (https://github.com/ansible-collections/community.general/pull/1036). diff --git a/plugins/cache/redis.py b/plugins/cache/redis.py index 37ced1a436..285f6c0bbc 100644 --- a/plugins/cache/redis.py +++ b/plugins/cache/redis.py @@ -32,6 +32,15 @@ DOCUMENTATION = ''' ini: - key: fact_caching_prefix section: defaults + _keyset_name: + description: User defined name for cache keyset name. + default: ansible_cache_keys + env: + - name: ANSIBLE_CACHE_REDIS_KEYSET_NAME + ini: + - key: fact_caching_redis_keyset_name + section: defaults + version_added: 1.3.0 _timeout: default: 86400 description: Expiration timeout in seconds for the cache plugin data. Set to 0 to never expire @@ -78,6 +87,7 @@ class CacheModule(BaseCacheModule): uri = self.get_option('_uri') self._timeout = float(self.get_option('_timeout')) self._prefix = self.get_option('_prefix') + self._keys_set = self.get_option('_keyset_name') except KeyError: display.deprecated('Rather than importing CacheModules directly, ' 'use ansible.plugins.loader.cache_loader', @@ -86,6 +96,7 @@ class CacheModule(BaseCacheModule): uri = C.CACHE_PLUGIN_CONNECTION self._timeout = float(C.CACHE_PLUGIN_TIMEOUT) self._prefix = C.CACHE_PLUGIN_PREFIX + self._keys_set = 'ansible_cache_keys' self._cache = {} kw = {} @@ -96,7 +107,6 @@ class CacheModule(BaseCacheModule): connection = uri.split(':') self._db = StrictRedis(*connection, **kw) - self._keys_set = 'ansible_cache_keys' def _make_key(self, key): return self._prefix + key