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

Function flush_

salt/cache/mmap_cache.py:243–273  ·  view source on GitHub ↗

Remove *key* from *bank*, or clear the entire *bank* if *key* is ``None``. Clearing a bank removes the mmap files from the registry and deletes them from disk, mirroring ``localfs`` behaviour where ``shutil.rmtree`` removes the bank directory.

(bank, key=None, cachedir=None, **kwargs)

Source from the content-addressed store, hash-verified

241
242
243def flush_(bank, key=None, cachedir=None, **kwargs):
244 """
245 Remove *key* from *bank*, or clear the entire *bank* if *key* is ``None``.
246
247 Clearing a bank removes the mmap files from the registry and deletes them
248 from disk, mirroring ``localfs`` behaviour where ``shutil.rmtree`` removes
249 the bank directory.
250 """
251 if cachedir is None:
252 cachedir = __cachedir()
253
254 if key is None:
255 # Flush entire bank: evict from registry, remove files from disk.
256 cache_key = (cachedir, bank)
257 entry = _caches.pop(cache_key, None)
258 if entry is not None:
259 entry[1].close()
260
261 bank_dir = salt.utils.path.join(cachedir, os.path.normpath(bank))
262 if not os.path.isdir(bank_dir):
263 return False
264
265 # Remove just the mmap files, leave the directory structure intact
266 # so that sub-banks are not inadvertently destroyed.
267 removed = False
268 index_base = os.path.join(bank_dir, ".mmap_cache.idx")
269 return _unlink_mmap_bank_files(index_base, strict_remove=True)
270
271 cache = _get_cache(bank, cachedir)
272 deleted = cache.delete(key)
273 return deleted
274
275
276def list_(bank, cachedir, **kwargs):

Callers

nothing calls this directly

Calls 6

_unlink_mmap_bank_filesFunction · 0.85
__cachedirFunction · 0.70
_get_cacheFunction · 0.70
popMethod · 0.45
closeMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected