当缓存asp.net到期回调 [英] Callback when cache expires in asp.net

查看:85
本文介绍了当缓存asp.net到期回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一个教程或一个例子,我怎么可以运行在asp.net中的函数,当缓存过期?我看了一下,当缓存过期它是由一个回调,但是我没有找到任何的例子。我需要这一个网站。它需要一个确切的时间,每天执行一个函数。

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 i didn't find any examples. I need this for a website. It needs to execute a function on an exact hour every day.

推荐答案

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;
        }

这篇关于当缓存asp.net到期回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆