I’m using .NET C# for a project.
I have a list of products which I want to cache as they’re used company wide. If the products drop out of cache I already know how to lock the cache and rebuild it ok as per the patterns on various authority/blog sites.
In my pages/user controls etc, I might grab a reference to the cache, like this:
var myCacheInstance = cachedProducts
However, I might also want to do something like this:
myCacheInstance.Add(new product(...));
Which will also update the cache as it’s the same object.
I have 2 queries.
- If I have a reference to the cached object is it guaranteed to remain in cache for the lifetime of my variable?
- In the scanario outlined above, how do I go about ensuring integrity? I’m only planning on adding in this instance, but suppose, I was updating and deleting objects as well?
If I right interpret this question: responce is no.
Can add
boolproperty like, for example:when object removed this property is set from the class to
false. Just example, iff it really fits your need can tell us only you.