【问题标题】:.Net MemoryCache - How to update expiration time for an existing item?.Net MemoryCache - 如何更新现有项目的到期时间?
【发布时间】:2012-11-21 11:04:53
【问题描述】:

Memcached API 有一个 Touch() 方法,用于更新给定键的过期策略。如何使用 .Net ObjectCache 类最好地完成此任务?

我能看到的最好的办法是删除对象并重新添加一个新的过期时间,但显然这是次优性能。

【问题讨论】:

    标签: .net caching memorycache


    【解决方案1】:

    很遗憾,无法重置缓存项的持续时间。

    但是,因为它是内存缓存(不像 memcached 那样分布式),所以获取和重新添加速度很快,就像传递引用一样。

    另一种选择是为您的缓存项使用 SlidingExpiration。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-15
      • 1970-01-01
      • 2014-05-21
      • 2018-05-10
      • 2019-08-13
      • 1970-01-01
      • 2014-04-06
      相关资源
      最近更新 更多