【问题标题】:Asp.net core Caching In-Memory and Distributed togetherAsp.net core Caching In-Memory 和 Distributed together
【发布时间】:2017-08-27 15:39:50
【问题描述】:

内存缓存和分布式缓存可以在同一个应用程序中一起使用吗?到底有意义吗?

我想到的一个逻辑场景是管理会话状态(在内存之上,利用粘性会话)和分布式以进行其他缓存。但是我不知道这是否有意义。

【问题讨论】:

  • 当然可以。您只需要管理缓存失效,这可能比仅使用分布式缓存有点棘手

标签: caching asp.net-core asp.net-caching


【解决方案1】:

是的,你可以。一个实现IMemoryCache,另一个实现IDistributedCache

如果您有非粘性会话和多个服务器,IMemoryCache 将无法正常工作。

您也可能想使用service.AddDistributedMemoryCache(); 而不是service.AddMemoryCache();

【讨论】:

    猜你喜欢
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-26
    • 2022-12-02
    • 2017-04-26
    相关资源
    最近更新 更多