ASP.Net CacheDependency 对象问题

发布于 2024-10-05 01:04:00 字数 587 浏览 1 评论 0原文

我想我知道这个问题的答案,但我在文档或文章中找不到明确的是或否。

使用 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹉夏雨初晴づ 2024-10-12 01:04:01

答案是否定的。尚未在缓存中的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文