What is the difference between the Cache.Add() and Cache.Insert() methods?
Cache.Add()
Cache.Insert()
In which situations should I use each one?
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.
Insert
Add
2.1m questions
2.1m answers
60 comments
57.0k users