Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheManager with With SystemRuntimeCache and Redis backplane does not receive events from the Redis cache. #296

Open
siraj-ur-rahman opened this issue Jan 3, 2020 · 0 comments

Comments

@siraj-ur-rahman
Copy link

siraj-ur-rahman commented Jan 3, 2020

I am using CacheManager for 2 layers of caching to increase speed across my applications.
I'm using InMemory cache along with Redis as a back plane.

I'm working with invalidating the local in-memory cache data. I have subscribed to the item update and remove event on redis cache but my application does not receive any events. When I run the command it shows that it has already subscribed to the channel which can be seen from the result of the command given below.

localhost:6379> pubsub channels *
1) "__Booksleeve_MasterChanged"
2) "CacheManagerBackplane"

The event registration code can be seen below:

ICacheManager<object> manager = GetCacheInstance();
            manager.OnRemoveByHandle += EventHandlerRemove;
            
 public void EventHandlerRemove(object sender, CacheItemRemovedEventArgs e){}

This is cache registration.

var manager = CacheFactory.Build<object>(settings => {
                settings.WithJsonSerializer();
                settings
                    .WithSystemRuntimeCacheHandle()
                    .And
                    .WithRedisConfiguration("redis", config => {
                        config.WithAllowAdmin()
                            .WithDatabase(0)
                            .WithEndpoint("localhost", 6379);
                    })
                    .WithRedisBackplane("redis")
                    .WithRedisCacheHandle("redis", true);
                settings.WithUpdateMode(CacheUpdateMode.None);
            });

Is there anything wrong with this code or do I require some additional configuration for this to make it work?

what I want to achieve:

I have Redis cache and multiple services are using this for invalidating their data using the events of this Redis cache. Each service have its own local in-memory cache related to the data in the main Redis cache. when the data is modified in the Redis cache each local cache will receive an event of data updated or removed from Redis cache and hence they will remove their local copy too to avoid serving stale data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant