【问题标题】:Azure Role Caching - Expiration time not workingAzure 角色缓存 - 过期时间不起作用
【发布时间】:2013-04-14 06:03:59
【问题描述】:

我正在 Azure WebRole 中运行角色缓存。 当我在缓存中插入对象时,我指定了 15 秒的时间跨度,但对象在插入后 1 分半过期。

问题是:过期时间有最小值吗..可以是15秒吗?

更新: 当我说对象在指定时间内没有过期时,我的意思是我在配置的时间内没有收到预期的“删除回调”。我有以下配置:

 DataCacheFactoryConfiguration config = new DataCacheFactoryConfiguration();
            config.NotificationProperties = new DataCacheNotificationProperties(1000, TimeSpan.FromSeconds(1));


            cacheFactory = new DataCacheFactory(config);
            cacheAbsolute = cacheFactory.GetCache("absolute");



            foreach (CacheAbsoluteRegion reg in Enum.GetValues(typeof(CacheAbsoluteRegion)))
            {
                cacheAbsolute.CreateRegion(reg.ToString());
                cacheAbsolute.AddRegionLevelCallback(reg.ToString(), DataCacheOperations.RemoveItem, new DataCacheNotificationCallback(RemoveCallback));
            }

在我添加一个时间跨度为 15 秒的对象后,在插入后 1 到 2 分钟之间调用回调。

【问题讨论】:

  • 您可以从您的设置中发布 Microsoft.WindowsAzure.Plugins.Caching.NamedCaches 字符串吗?
  • {“caches”:[{“name”:“default”,“policy”:{“eviction”:{“type”:0},“expiration”; :{“defaultTTL”:1,“isExpirable”:true,“type”:2},“serverNotification”:{“isEnabled”:true}},“secondaries”:0},{“ name”:“absolute”,“policy”:{“eviction”:{“type”:0},“expiration”:{“defaultTTL”:10,“isExpirable”:true,” type“:1}”,“serverNotification”:{“isEnabled”:true}},“secondaries”:0}]}
  • 有2个命名缓存,一个有滑动过期,另一个是绝对过期。

标签: azure azure-caching


【解决方案1】:

确保您使用的是类似的东西:

cache.Add("item", "value", TimeSpan.FromSeconds(15));

并且您的缓存设置为“绝对”到期,而不是“滑动”。 Read more here...

【讨论】:

  • 是的,我确定我添加了 15 秒的时间跨度,并且设置为绝对到期
  • 奇怪的是,切换到绝对到期为我解决了这个问题。不确定到期的性质与驱逐本身有什么关系。从逻辑上讲,应该可以有滑动+过期...
猜你喜欢
  • 1970-01-01
  • 2011-11-08
  • 2012-03-02
  • 2013-12-20
  • 1970-01-01
  • 2016-07-20
  • 2018-05-01
  • 2013-07-17
  • 1970-01-01
相关资源
最近更新 更多