Callback when cache expires in asp.net

后端 未结 2 1280
别那么骄傲
别那么骄傲 2021-01-07 02:28

Does anyone know a tutorial or an example on how can i run a function in asp.net, when a cache expires? I have read about a callback which is made when a cache expires, but

2条回答
  •  执笔经年
    2021-01-07 02:56

    hhh3112,

    You can use a callback when the cache expires. can you explain a little more. I am not sure what you mean by the process has to execute on an exact hour of everyday.

    string test = "test1";
    Cache.Insert("Key", test, dependancy, DateTime.Now.AddMinutes(DateTime.Now), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, new CacheItemRemovedCallback(CacheRemovedCallback));
    
    public string CacheRemovedCallback(String key, object value, System.Web.Caching.CacheItemRemovedReason removedReason)
    {
        //Do something here
        return  = "Cache Expired for : " + key;
    }
    

提交回复
热议问题