Skip to content

Instantly share code, notes, and snippets.

@s-hertel
Last active June 11, 2019 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-hertel/50f72d8f521378225a3cdc0b42644509 to your computer and use it in GitHub Desktop.
Save s-hertel/50f72d8f521378225a3cdc0b42644509 to your computer and use it in GitHub Desktop.
diff --git a/lib/ansible/plugins/cache/__init__.py b/lib/ansible/plugins/cache/__init__.py
index fbc4122aca..6de6a064c5 100644
--- a/lib/ansible/plugins/cache/__init__.py
+++ b/lib/ansible/plugins/cache/__init__.py
@@ -306,10 +306,9 @@ class CachePluginAdjudicator(MutableMapping):
def _do_load_key(self, key):
load = False
if key not in self._cache and key not in self._retrieved and self._plugin_name != 'memory':
- if isinstance(self._plugin, BaseFileCacheModule):
- load = True
- elif not isinstance(self._plugin, BaseFileCacheModule) and self._plugin.contains(key):
- # Database-backed caches don't raise KeyError for expired keys, so only load if the key is valid by checking contains()
+ # Note that only file-backed caches raise a KeyError using self._plugin.get(), but will also give an unwarranted warning
+ # check whether the plugin contains the Key for uniformity between file-backed and database-backed caches
+ if self._plugin.contains(key):
load = True
return load
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment