码迷,mamicode.com
首页 > 系统相关 > 详细

MemoryCache

时间:2019-04-25 11:49:05      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:caller   als   clu   link   microsoft   out   mic   port   false   

https://docs.microsoft.com/en-us/dotnet/api/system.runtime.caching.memorycache?view=netframework-4.8

 

What‘s the difference between MemoryCache.Add and MemoryCache.Set?

 

Add does nothing (returns false) if there is already a value for that key. Set does an insert or update, as necessary.

Remove + Add would leave a gap in the middle when another thread querying that key would get no clue (Set does not; the swap is typically atomic); as such, while Set has the same end result as Remove + Add, the mechanism difference is important since it could impact other callers.

For example of Add:

Return Value

Type: System.Boolean true if insertion succeeded, or false if there is an already an entry in the cache that has the same key as key. 

 

MemoryCache

标签:caller   als   clu   link   microsoft   out   mic   port   false   

原文地址:https://www.cnblogs.com/chucklu/p/10767353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!