gpt4 book ai didi

.net-core - 当我们有 IDistributedCache 时,为什么要使用 IMemoryCache?

转载 作者:行者123 更新时间:2023-12-04 11:48:48 32 4
gpt4 key购买 nike

.Net Core 为两个接口(interface)( MemoryCacheDistributedMemoryCache )提供内存实现,但假设我们有一个可用的 IDistributedCache我们的应用程序的实现。

什么时候仍然使用 IMemoryCache 有意义.在什么情况下它比在分布式缓存中缓存数据更有帮助或更受欢迎?

最佳答案

我正在寻找相同的内容,并在 github 问题中找到了答案:

They have fundamentally different semantics. MemoryCache can store live objects, the distributed cache can't, objects have to be serialized. The distributed cache can be off box and calls to it may fail or take a long time so getting and setting should be async, the MemoryCache is always in memory and fast. The distributed cache can be disconnected from the store so the interface should account for that.


https://github.com/aspnet/Caching/issues/220#issuecomment-241229013

关于.net-core - 当我们有 IDistributedCache 时,为什么要使用 IMemoryCache?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59791959/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com