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

Not possible to flush whole cache when using in-memory and redis handles #360

Open
djb-frog opened this issue Oct 20, 2021 · 2 comments
Open

Comments

@djb-frog
Copy link

Our caching configuration uses both in-memory cache and Redis. Additionally we rely on Redis keyspace notifications to clear keys from the in-memory caches across all our app service instances.

One problem we are having is something bad gets into the cache, we want to flush redis and also flush in-memory cache on all instances. Is this possible? Does ICacheManager.Clear propagage the cache clear to clear in-memory cache on all instances?

Assuming it doesn't, I was thinking we could use a region that contains all our cache items so we can clear the region to clear Redis and all the instance caches in one go. Is it possible to prefix all our regions with a global region name? My testing indicates that each cache item can only belong to one region and there is no concept of multiple regions or region prefixes.

If I create items in regions called "ALL:regionone", "ALL:regiontwo"

// This works as expected:
_cacheManager.DeleteRegion("ALL:regionone");

// Didn't 100% expect this to work, but this does not clear any of my items:
_cacheManager.DeleteRegion("ALL");

Any advice greatly appreciated!

David

@djb-frog
Copy link
Author

Hi,

I just tried it out some tests again and your Clear action is being propagated with Redis between my 2 test instances - apologies for the false alarm!

So that's my main problem fixed :)
I guess I'm just wondering if you can confirm is there any way to have more than 1 region or region prefix associated with a cached item?

Thanks

David

@MichaCo
Copy link
Owner

MichaCo commented Oct 21, 2021

Yeah clear should just work.

One key can currently only be on one region, but you can ofc add the key to multiple regions, would just be Add multiple calls for example.

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

2 participants