ASP.NET缓存添加VS插入 [英] ASP.NET cache add vs insert

查看:78
本文介绍了ASP.NET缓存添加VS插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么

Cache.Add 

Cache.Insert

方法呢?

在什么情况下应该使用第一个,第二个?

In what situations should I use first, and the second one?

推荐答案

插入将覆盖具有相同的键现有的缓存值; 添加失败(什么都不做),如果使用相同的密钥现有的缓存值。所以这是一个案例,说你应该总是使用插入以来第一次code运行时,它会将你的对象到缓存中,当它运行之后,将更新缓存值。

Insert will overwrite an existing cached value with the same Key; Add fails (does nothing) if there is an existing cached value with the same key. So there's a case for saying you should always use Insert since the first time the code runs it will put your object into the cache and when it runs subsequently it will update the cached value.

这篇关于ASP.NET缓存添加VS插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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