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

Function _flush_key

salt/cache/redis_cache.py:300–316  ·  view source on GitHub ↗

Remove the key from the cache. If this is the last key in the bank then also remove the bank from the list of banks.

(bank, key)

Source from the content-addressed store, hash-verified

298
299
300def _flush_key(bank, key):
301 """
302 Remove the key from the cache.
303
304 If this is the last key in the bank then also remove the bank from the list of banks.
305 """
306 redis_server = _get_redis_server()
307 bank_key, timestamp_key = _normalize_bank(bank)
308 redis_pipe = redis_server.pipeline()
309 redis_pipe.hdel(bank_key, key)
310 redis_pipe.hdel(timestamp_key, key)
311 redis_pipe.exists(bank_key)
312 batch_results = redis_pipe.execute()
313 # I wish this could be made atomic, but it relies on the previous result. Scripts could make it
314 # atomic, but that's a lot of overhead..
315 if not batch_results[-1]:
316 redis_server.zrem(_banks_set_key(), bank_key)
317
318
319def _flush_bank(bank):

Callers 1

flushFunction · 0.85

Calls 8

_get_redis_serverFunction · 0.85
_normalize_bankFunction · 0.85
_banks_set_keyFunction · 0.85
pipelineMethod · 0.80
hdelMethod · 0.80
zremMethod · 0.80
existsMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected