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)
| 241 | |
| 242 | |
| 243 | def 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 | |
| 276 | def list_(bank, cachedir, **kwargs): |
nothing calls this directly
no test coverage detected