I think I know the answer to this but I cannot find a definitive yes or no anywhere in documentation or articles.
Using .Net 3.5 ASP.Net caching, if you make a CacheDependency passing a string[] of cacheKeys, do those passed cacheKeys get inserted into the cache on the Insert in which the dependency is used on if they do not already exist?
CacheDependency dependency =
new CacheDependency(null, new string[] { "abc", "def", "ghi"});
HttpRuntime.Cache.Insert("123", "xxx", dependency);
So when cache item "123" gets inserted, what if there isn't already an item in cache with the key "def"? Does it then get created?
If not, is there a way to then take that CacheDependency object, and find out what keys it was created with, so I can then loop thru them and add each as needed?
Basically, I trying to allow a CacheDependency object to be passed into my custom CacheManager object methods for dependencies instead of the string[] array I require now. Thanks for any help you can provide.
The answer is no. The cacheKeys of a cacheDependency that are not already in cache ARE NOT inserted into the cache on the Insert of the item in which the dependency is used.
In fact, the actual item being Inserted with the dependency does not even make it into the cache because its dependency does not already exist in cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With