Azure角色缓存 - 到期时间不起作用

时间:2013-04-12 19:37:58

标签: azure azure-caching

我在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分钟内调用回调。

1 个答案:

答案 0 :(得分:1)

确保您使用的是:

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

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

相关问题