mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* FEATURE: make ansible_cache_keys name configurable
* REFACTOR: rename cache_keys to keyset
* FEATURE: add changelog fragment
* Update changelogs/fragments/1036-redis-cache-keyset-name.yaml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Set version_added in plugins/cache/redis.py
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Benjamin Pereto <benjamin@sandchaschte.ch>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 873f1fb7fd
)
Co-authored-by: Benjamin Pereto <dev@sandchaschte.ch>
This commit is contained in:
parent
dd47c3a548
commit
6092cd89bc
2 changed files with 14 additions and 1 deletions
3
changelogs/fragments/1036-redis-cache-keyset-name.yaml
Normal file
3
changelogs/fragments/1036-redis-cache-keyset-name.yaml
Normal file
|
@ -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).
|
12
plugins/cache/redis.py
vendored
12
plugins/cache/redis.py
vendored
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue