Closed overheadhunter closed 1 year ago
Slightly off-topic: This also fixes #160 (should already be fixed in #48). It has been wrong all the time, but apparently the error didn't occur during tests with the old implementation, therefore I decided to include this in this PR.
This is a new attempt of fixing #158 while retaining the ability to concurrently read from the same open file.
The ChunkCache will now make sure not to recycle any chunk as long as it is still being used ("active chunk" - using reference counting and AutoCloseable). When no longer active, chunks are moved to a "stale" cache, invalidating LRU chunks eventually.