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)
| 298 | |
| 299 | |
| 300 | def _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 | |
| 319 | def _flush_bank(bank): |
no test coverage detected