ASP.Net CacheDependency 对象问题
我想我知道这个问题的答案,但我在文档或文章中找不到明确的是或否。
使用 .Net 3.5 ASP.Net 缓存,如果您创建 CacheDependency 并传递 cacheKeys 的 string[],那么这些传递的 cacheKeys 是否会插入到使用依赖项的 Insert 上的缓存中(如果它们尚不存在)?
CacheDependency dependency =
new CacheDependency(null, new string[] { "abc", "def", "ghi"});
HttpRuntime.Cache.Insert("123", "xxx", dependency);
因此,当插入缓存项“123”时,如果缓存中还没有具有键“def”的项怎么办?然后它会被创建吗?
如果没有,有没有办法获取该 CacheDependency 对象,并找出它是使用哪些键创建的,以便我可以循环遍历它们并根据需要添加每个键?
基本上,我试图允许将 CacheDependency 对象传递到我的自定义 CacheManager 对象方法中以获取依赖项,而不是我现在需要的 string[] 数组。感谢您提供的任何帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是否定的。尚未在缓存中的cacheDependency 的cacheKey 不会在使用依赖项的项目插入时插入到缓存中。
事实上,与依赖项一起插入的实际项目甚至没有进入缓存,因为它的依赖项尚不存在于缓存中。
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.