Why does Cache.Add return an object that represents the cached item?
Posted
by Pure.Krome
on Stack Overflow
See other posts from Stack Overflow
or by Pure.Krome
Published on 2009-08-17T06:04:33Z
Indexed on
2010/05/31
4:52 UTC
Read the original article
Hit count: 217
From MSDN about the differences between Adding or Inserting an item the ASP.NET Cache:
Note: The Add and Insert methods have the same signature, but there are subtle differences between them. First, calling the Add method returns an object that represents the cached item, while calling Insert does not. Second, their behavior is different if you call these methods and add an item to the Cache that is already stored there. The Insert method replaces the item, while the Add method fails. [emphasis mine]
The second part is easy. No question about that.
But with the first part, why would it want to return an object that represents the cached item? If I'm trying to Add an item to the cache, I already have/know what that item is?
I don't get it. What is the reasoning behind this?
© Stack Overflow or respective owner