MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.34k stars 457 forks source link

Storing int values #253

Closed theperiscope closed 5 years ago

theperiscope commented 5 years ago

During a cache contents review, I found out that ICacheManager<int> manager skips storing the value in MemoryCache using the configuration below. Switching to a class with single int field resolved issue, and the value was stored in both MemoryCache and Redis as expected.

<managers>
  <cache name="defaultCache" enableStatistics="false" enablePerformanceCounters="false" updateMode="Up" backplaneName="redisConnectionStringWithDefaultDb" backplaneType="CacheManager.Redis.RedisCacheBackplane, CacheManager.StackExchange.Redis" serializerType="CacheManager.Serialization.Json.JsonCacheSerializer, CacheManager.Serialization.Json">
    <handle name="default" ref="systemRuntimeHandle" expirationMode="Sliding" timeout="20m" />
    <handle name="redisConnectionStringWithDefaultDb" ref="redisSliding" expirationMode="None" isBackplaneSource="true" />
  </cache>
</managers>
<cacheHandles>
  <handleDef id="redisSliding" type="CacheManager.Redis.RedisCacheHandle`1, CacheManager.StackExchange.Redis" defaultExpirationMode="Sliding" defaultTimeout="5m" />
  <handleDef id="systemRuntimeHandle" type="CacheManager.SystemRuntimeCaching.MemoryCacheHandle`1, CacheManager.SystemRuntimeCaching" defaultExpirationMode="Sliding" defaultTimeout="5m"/>
</cacheHandles>
MichaCo commented 5 years ago

Hi @internal-override, what do you mean with "skips storing the value in MemoryCache"?

In case you use the Add method with 2 layers, the item would be added only to redis first. Maybe that's what you saw?

theperiscope commented 5 years ago

Hi @MichaCo,

what do you mean with "skips storing the value in MemoryCache"?

With the same configuration other (reference type) items got inserted into both the MemoryCache and redis

In case you use the Add method with 2 layers, the item would be added only to redis first. Maybe that's what you saw?

I am using Put method, I'll try to upload sample code later today to help demonstrate the issue.

theperiscope commented 5 years ago

Unable to reproduce issue this morning, closing for now due to inconsistency.