Skip to content

Fix several LRUMemoryCache cache size bugs

Jeremiah Bonney requested to merge jbonney/lru-cache-fixes into master

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:

  1. Update delete_blob to decrement self._bytes_stored when removing a blob from the cache, and also take the lock when doing so.
  2. Update commit_write to not increment self._bytes_stored if the blob being written already exists in the cache, and instead mark it as recently read.
  3. Update commit_write to only increment self._bytes_stored after the blob has been written to the cache, to make it more robust against unexpected exceptions.

Merge request reports