alastairtree / LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
https://nuget.org/packages/LazyCache
MIT License
1.72k stars 159 forks source link

Exposes Compact #172

Open judahr opened 2 years ago

judahr commented 2 years ago

For issue #171

Exposes Compact as found in MemoryCache. Other providers would have to implement or expose their own as ICacheProvider was changed.

From code comments in MemoryCache:

/// Remove at least the given percentage (0.10 for 10%) of the total entries (or estimated memory?), according to the following policy:
        /// 1. Remove all expired items.
        /// 2. Bucket by CacheItemPriority.
        /// 3. Least recently used objects.
        /// ?. Items with the soonest absolute expiration.
        /// ?. Items with the soonest sliding expiration.
        /// ?. Larger objects - estimated by object graph size, inaccurate.

https://github.com/dotnet/runtime/blob/release/6.0/src/libraries/Microsoft.Extensions.Caching.Memory/src/MemoryCache.cs#L382-L393

alastairtree commented 2 years ago

Might be better to have MemoryCacheProvider expose the IMemoryCache and then you can cast and compact (and access everything else on that class) , rather than requiring all providers to implement an interface that may not be relevant.