Fix several LRUMemoryCache cache size bugs
Description
This MR fixes a handful of issues that LRUMemoryCache
has, specifically with how the cache size gets out of sync with reality.
The three issues I fixed are:
- Update
delete_blob
to decrementself._bytes_stored
when removing a blob from the cache, and also take the lock when doing so. - Update
commit_write
to not incrementself._bytes_stored
if the blob being written already exists in the cache, and instead mark it as recently read. - Update
commit_write
to only incrementself._bytes_stored
after the blob has been written to the cache, to make it more robust against unexpected exceptions.