cache.Insert("test", content, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(2));
我设置2分钟失效。但是在这2分钟里,我刷新1次页面,catch中的test就不丢失,以后每1分钟刷新1次,直到10分钟,
test还是不丢失。我像实现不管页面刷不刷新,2分钟后失效该怎么办?

解决方案 »

  1.   

    你要先判断有没有cache,没有的话insert,有的话用cache,过期了cache自然就没了,你这样一遍遍的insert cache永远是新加入的。
      

  2.   

    有判断的
    if (content == null)
    {
    content = datatime.now.tostring(); cache.Insert("test", content, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(2)); 
    }
      

  3.   

    应该是这么判断吧,你那是什么,我没看懂
    if(Cache["test"]==null)