MCPcopy Index your code
hub / github.com/saltstack/salt / fetch

Function fetch

salt/cache/mmap_cache.py:204–226  ·  view source on GitHub ↗

Return the deserialised value for *bank*/*key*, or ``{}`` if not found.

(bank, key, cachedir, **kwargs)

Source from the content-addressed store, hash-verified

202
203
204def fetch(bank, key, cachedir, **kwargs):
205 """
206 Return the deserialised value for *bank*/*key*, or ``{}`` if not found.
207 """
208 cache = _get_cache(bank, cachedir)
209 raw = cache.get(key, default=None)
210
211 if raw is None:
212 return {}
213
214 # set-mode entries (value=True) indicate presence without data
215 if raw is True:
216 return {}
217
218 if isinstance(raw, str):
219 raw = raw.encode()
220
221 try:
222 return msgpack.unpackb(raw, **_UNPACK_OPTS)
223 except Exception as exc: # pylint: disable=broad-except
224 raise SaltCacheError(
225 f"Failed to deserialise cache data for bank={bank!r} key={key!r}: {exc}"
226 )
227
228
229def updated(bank, key, cachedir, **kwargs):

Callers

nothing calls this directly

Calls 3

SaltCacheErrorClass · 0.90
_get_cacheFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected