Add new method GetItemsAndFlush
Author: oGabrielArrudaCreated Sep 4, 2024Updated Sep 12, 2024
We are facing a situation where we need to flush the entire cache while capturing a snapshot of its exact state before doing so.
Using the Itemsfunction followed by Flush is not concurrent safe because a Set operation could occur between the two calls, resulting in the Flush call mistakenly deleting newly added items.
A workaround would be to use a mutex that prevents writes while these two sequential calls are being made. However, it is much simpler and more efficient to use the library's existing mutex.
Source: patrickmn/go-cache