MCPcopy
hub / github.com/saltstack/salt / fetch

Method fetch

salt/cache/__init__.py:171–203  ·  view source on GitHub ↗

Fetch data using the specified module :param bank: The name of the location inside the cache which will hold the key and its associated data. :param key: The name of the key (or file inside a directory) which will hold the da

(self, bank, key)

Source from the content-addressed store, hash-verified

169 return self.modules[fun](bank, key, data, **self.kwargs)
170
171 def fetch(self, bank, key):
172 """
173 Fetch data using the specified module
174
175 :param bank:
176 The name of the location inside the cache which will hold the key
177 and its associated data.
178
179 :param key:
180 The name of the key (or file inside a directory) which will hold
181 the data. File extensions should not be provided, as they will be
182 added by the driver itself.
183
184 :return:
185 Return a python object fetched from the cache or an empty dict if
186 the given path or key not found.
187
188 :raises SaltCacheError:
189 Raises an exception if cache driver detected an error accessing data
190 in the cache backend (auth, permissions, etc).
191 """
192 fun = f"{self.driver}.fetch"
193 ret = self.modules[fun](bank, key, **self.kwargs)
194
195 # handle fallback if necessary
196 if isinstance(ret, dict) and set(ret.keys()) == {"data", "_expires"}:
197 now = datetime.datetime.now().astimezone().timestamp()
198 if ret["_expires"] > now:
199 return ret["data"]
200 else:
201 return {}
202 else:
203 return ret
204
205 def updated(self, bank, key):
206 """

Callers 15

cacheMethod · 0.95
fetchFunction · 0.95
migrateFunction · 0.95
gen_acceptFunction · 0.95
iter_bank_chunksFunction · 0.95
_fetch_minion_keyFunction · 0.95
_fetch_minion_keyFunction · 0.95

Calls 3

nowMethod · 0.80
setFunction · 0.50
keysMethod · 0.45