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

OnRemoveByHandle not working with Redis #224

Closed arrkaye closed 6 years ago

arrkaye commented 6 years ago

Hi,

I've configured my cache as below, but am not getting the OnRemoveByHandle called.

Configuration = new ConfigurationBuilder() .WithJsonSerializer() .WithRedisConfiguration("redis", c => { var connectionString = cp.DataOptions.Cache.Split(":"); c .WithAllowAdmin() .EnableKeyspaceEvents() .WithEndpoint(connectionString[0], int.Parse(connectionString[1])); }) .WithRedisBackplane("redis") .WithRedisCacheHandle("redis", true).Build();

Cache is being created like so:

_cache = CacheFactory.FromConfiguration<T>(Configuration); _cache.OnRemoveByHandle += OnExpiry; I see the item being added and expired from the cache in RedisDesktopManager.

Any idea what I could be doing wrong?

MichaCo commented 6 years ago

Do you have key space events with the required settings enabled on the Redis server?

arrkaye commented 6 years ago

What value does that need to be set to in the redis.conf?

MichaCo commented 6 years ago

https://github.com/MichaCo/CacheManager/blob/dev/src/CacheManager.StackExchange.Redis/RedisConfigurationBuilderExtensions.cs#L44

arrkaye commented 6 years ago

Figured it out. Thanks!

MichaCo commented 6 years ago

Great ;)