Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET cache add vs insert

What is the difference between the Cache.Add() and Cache.Insert() methods?

In which situations should I use each one?

like image 244
guchko-gleb Avatar asked Jun 26 '11 17:06

guchko-gleb


1 Answers

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.

like image 171
PhilPursglove Avatar answered Sep 28 '22 04:09

PhilPursglove