如何清除内存缓存? [英] How to clear MemoryCache?

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

问题描述

我使用 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?

推荐答案

Dispose 现有的 MemoryCache 并创建一个新的 MemoryCache 对象.

Dispose the existing MemoryCache and create a new MemoryCache object.

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

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