如何清除.NET 4的MemoryCache [英] How to clear the .net 4 MemoryCache

查看:1612
本文介绍了如何清除.NET 4的MemoryCache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建使用MemoryCache类的缓存。我想补充一些项目,但是当我需要重新加载缓存我想先清除它。什么是做到这一点的最快方法?我遍历所有的项目,应该删除它们一次,或是否有更好的办法?

I have created a cache using the MemoryCache class. I add some items to it but when I need to reload the cache I want to clear it first. What is the quickest way to do this? Should I loop through all the items and remove them one at a time or is there a better way?

推荐答案

<一个href=\"http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.dispose.aspx\"><$c$c>Dispose现有的MemoryCache并创建一个新的MemoryCache对象。

Dispose the existing MemoryCache and create a new MemoryCache object.

这篇关于如何清除.NET 4的MemoryCache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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