Closed nflash closed 4 years ago
I had made the change to throw an exception when trying to set options for the Default cache. I have also added some more tests, including a test expecting the exception.
For unit testing, can you add/change one of the shared cache configurations used by many other tests to use the new way of configuring this cache handle? For example, change this one https://github.com/MichaCo/CacheManager/blob/dev/test/CacheManager.Tests/TestCacheManagers.cs#L332
What kind of change do you suggest? Something like this?
public static ICacheManager<object> WithMemoryAndDictionaryHandles
=> CacheFactory.FromConfiguration<object>(
BaseConfiguration
.Builder
.WithSystemRuntimeCacheHandle()
.EnableStatistics()
.And.WithSystemRuntimeCacheHandle("LimitedCacheHandle", new SystemRuntimeCaching.RuntimeMemoryCacheOptions() { PhysicalMemoryLimitPercentage = 20, CacheMemoryLimitMegabytes = 200 })
.EnableStatistics()
.WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(1000))
.And.WithDictionaryHandle()
.EnableStatistics()
.And.WithDictionaryHandle()
.EnableStatistics()
.WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(1000))
.Build());
I'm asking because I don't want to break any test by, for instance, setting a cache too small or by changing the number of cache handles
Great! Re. unit test. Yeah, that shouldn't break anything, that change should be good enough
In response to #177 the
RuntimeMemoryCacheOptions
class was created to allow configuring theSystem.Runtime.Caching.MemoryCache
.All overloads of the extension method
WithSystemRuntimeCacheHandle
with aRuntimeMemoryCacheOptions
parameter also requires theinstanceName
parameter because as I understand it, it is not possible to change the Default cache settings.Configuration with web/app configuration system still works as before and I think is the only way to configure the default cache.
For the MS.Extensions.Configuration I think I would need some guidance.