VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 50 forks source link

Cache cleans after app reload #44

Closed grinay closed 5 years ago

grinay commented 5 years ago

Summary of the issue

I'm using Redis cache as handle. Everything work until i reload app, then it stop using existing redis cache, and make every request new cache/ Is it expected behavior? How can I avoid that. I want my app to work with the same cache after restart app.

Environment

The in-use version:
Operating system: 
IDE: (e.g. Visual Studio 2015)

Example code/Steps to reproduce:

      var jss = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            };

   const string redisConfigurationKey = "redis";
            services.AddSingleton(typeof(ICacheManagerConfiguration),
                new CacheManager.Core.ConfigurationBuilder()
                    .WithJsonSerializer(serializationSettings: jss, deserializationSettings: jss)
                    .WithRedisConfiguration(redisConfigurationKey, redisConnectionString)
                    .WithUpdateMode(CacheUpdateMode.Up)
                    .WithMaxRetries(100)
                    .WithRetryTimeout(50)
                    .WithRedisCacheHandle(redisConfigurationKey)
                    .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromMinutes(10))
                    .Build());

Output:

Exception message:
Full Stack trace:
VahidN commented 5 years ago

Is it expected behavior?

Yes. App reload will create new hash-keys, so old ones won't be used again.

grinay commented 5 years ago

How to avoid that? This is suppose to be a distributed cache between few instances.

VahidN commented 5 years ago

You can't. It is as long as it's not reloaded.

VahidN commented 5 years ago

It's fixed via #https://github.com/VahidN/EFSecondLevelCache.Core/commit/23a076d973607903953ba52bcc629aad2d44e760

grinay commented 5 years ago

Awesome. Thanks.Really appreciate your efforts.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.