What is the difference between HttpContext.Current.Cache.Insert and HttpContext.Current.Cache.Add? Options

codeling 1302 - 5562
@2015-12-22 13:41:50

HttpContext.Current.Cache.Add method adds the specified item to the Cache object, whereas HttpContext.Current.Cache.Insert method inserts an item into the Cache object.

The main difference between these two methods is that if an object with the same name already exists in the cache, the Insert method call will replace the object, whereas the Add method call will fail.

The other main difference is also that with the Add method some parameters are mandatory, whereas with Insert method, various overloaded methods are available, and some parameters will be set to default values like the absolute or sliding expirations.

Users browsing this topic