admin管理员组文章数量:1418680
The Microsoft.Extensions.Caching.Hybrid package (available in .NET 9) provides a hybrid caching mechanism that allows you to combine both in-memory caching (for fast local access) and distributed caching (such as Redis) for microservices running in multiple pods.
How It Works in a Microservices Setup with Multiple Pods? If data is stored in-memory also, each pod uses its own memory, so if data is refreshed or updated in one pod, how to invalidate the in-memory cache in other pods so it do not return the stale data?
As far as I know, when we use in-memory for data storage in multiple pods application, there is no way the data changed in one pod would get changed in other pods also without any custom implementation. But, want to see if there is anything handled for this usecase within the HybridCache library itself which could handle the multiple pods scenario well and data gets refreshed in each pod?
The Microsoft.Extensions.Caching.Hybrid package (available in .NET 9) provides a hybrid caching mechanism that allows you to combine both in-memory caching (for fast local access) and distributed caching (such as Redis) for microservices running in multiple pods.
How It Works in a Microservices Setup with Multiple Pods? If data is stored in-memory also, each pod uses its own memory, so if data is refreshed or updated in one pod, how to invalidate the in-memory cache in other pods so it do not return the stale data?
As far as I know, when we use in-memory for data storage in multiple pods application, there is no way the data changed in one pod would get changed in other pods also without any custom implementation. But, want to see if there is anything handled for this usecase within the HybridCache library itself which could handle the multiple pods scenario well and data gets refreshed in each pod?
Share Improve this question edited Jan 30 at 20:37 Guru Stron 144k11 gold badges172 silver badges212 bronze badges asked Jan 29 at 13:23 Maitri DaveMaitri Dave 231 silver badge4 bronze badges1 Answer
Reset to default 1But, want to see if there is anything handled for this usecase within the HybridCache library itself which could handle the multiple pods scenario well and data gets refreshed in each pod?
No, currently there is nothing of the sorts. This is covered in the docs in Cache storage section:
When invalidating cache entries by key or by tags, they are invalidated in the current server and in the secondary out-of-process storage. However, the in-memory cache in other servers isn't affected.
It would be even hard to workaround at the moment since the is no publicily exposed APIs to invalidate (remove) only local cache data since HybridCache.RemoveAsync
will clear both local and distributed cache. But if you are OK with rewriting local one via HybridCache.SetAsync
then you can create some pub/sub (for example on Redis) which will handle "remote" cache invalidation.
This issue is discussed in [API Proposal]: Cache Synchronization for Hybrid Caching in Multi-Node Environments issue at github.
Also you can look into FusionCache
which AFAIK already has such feature.
本文标签: netHow Microsoft HybridCache works in a Microservice Setup with Multiple PodsStack Overflow
版权声明:本文标题:.net - How Microsoft HybridCache works in a Microservice Setup with Multiple Pods - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745295483a2652050.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论