views:

20

answers:

1

Hi folks,

If i have an item that already exists in my ASP.NET Cache ... and I just wish to update the value of that cached item .. not the Absolute Expiry value, or Cache Dependencies, etc.. nothing else BUT the value ... can I use Cache.Insert?

If not, is there anyway I can retrieve all those values for the cached item .. and then re-use them when I do the Cache.Insert?

Cheers :)

A: 

The Cache.Insert overload that takes just the key and object will simply use default values for the caching behaviour.

From MSDN:

Inserts an item into the Cache object with a cache key to reference its location, using default values provided by the CacheItemPriority enumeration.

You'd be best to create your own helper class to store the values for you as I don't believe there's a way to get at the cached item's behavioural properties.

David Neale
So it's an over-write? I was thinking as much.
Pure.Krome
Yes, `Cache.Insert` simply overwrites the `Cache` key. I don't know of any way to get at the caching properties so your wrapper would need to take care of that.
David Neale