开发者

Write to file when cache expires

How 开发者_如何学运维to write to a file the content of cache when Cache expires.


I'm assuming you're using ASP.Net, and you would like to write the content of a particular cached item?

To accomplish this, insert the item into the cache with a callback function specified for when the item is removed. For example:

Cache.Insert("MyText", someTextVariable, null, DateTime.Now.AddSeconds(10), 
             TimeSpan.Zero, CacheItemPriority.High, 
             new CacheItemRemovedCallback(ItemRemoved))


public void ItemRemoved(string key, object value, CacheItemRemovedReason reason)
{
    // write value to file
}

If this isn't what you're talking about, you're going to have to give more details in your question, because it's pretty vague.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜