appfabric 缓存标签背后的想法是什么

发布于 2024-12-23 17:03:18 字数 152 浏览 2 评论 0原文

我一直在阅读有关 appfabric 缓存的内容。其中一项功能是标记缓存条目。这有什么用?一些示例提到使用类别标记产品,然后使用该标签查询该类别中的所有产品。但我不明白这是如何工作的,因为我不知道如何保证所有产品实际上都在缓存中,从而使通过标签进行的整个查询变得毫无用处。我在这里缺少什么?

I've been reading about appfabric caching. And one of the features is tagging cache entries. What would this be useful for? Some of the examples mention tagging products with their category and then using the tag to query for all products in the category. But I don't understand how this would work since I don't see how you can guarantee all products are actually in the cache making the whole query by tag things rather useless. What am I missing here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

故笙诉离歌 2024-12-30 17:03:18

首先要解决您的“如何保证所有产品都在缓存中”的问题,我认为这是一个完全有效的批评。当我完成标记功能的演示时,我在应用程序启动时将所有产品加载到缓存中,并适当地标记它们 - 这是我想出的唯一可靠的方法。

就标记的用途而言,我认为它为您提供了从缓存中检索项目的额外选项。请记住,您可以为每个缓存的项目分配一个 IEnumerable,因此,为了遵循产品示例以及类别,您可以使用供应商或其他事物来标记每个项目产品类别集,例如“FreeDelivery”或“LowStock”。

或者,根据您向用户呈现的方式,您可以深入一组产品,构建一组标签来搜索缓存,例如从“男装”开始,然后添加“针织品” ,然后是“颜色:黑色”,然后是“尺寸:L”,向用户显示一组较窄的产品,并将每个标签添加到搜索中。

To address your 'how you can guarantee all products are in the cache' point first, I think it's a completely valid criticism. When I've done demos of the tagging feature, I've loaded all the products into the cache when the application starts, tagging them appropriately - it's the only reliable approach I've come up with.

In terms of what tagging is useful for, I see it as giving you extra options for retrieving items from the cache. Remember that you can assign an IEnumerable<DataCacheTag> to each cached item, so to follow through with the products example, as well as the category you could tag each item with the supplier, or with things that go across the set of product categories such as 'FreeDelivery' or 'LowStock'.

Or depending on how you present it to the user, you could drill into a set of products, building up a set of tags to search the cache for e.g. begin with 'Menswear', then add 'Knitwear', then 'Colour:Black', then 'Size:L', showing a narrower set of products to the user with each tag added to the search.

深海少女心 2024-12-30 17:03:18

标签是可用于对缓存项目进行分类的机制之一。如果您有一组包含可能相互关联的数据的缓存键,这可能会很有用。如果您更新了支持其中一个键的数据,您还需要确保其他键无效,以确保消费者不会从缓存中获得不一致的数据。另一种方法是创建一个仅包含相关键的缓存区域。

Tags are one of the mechanisms you can use to categorize your cached items. This could be useful if you had a set of cache keys which contained data that was potentially interrelated. If you updated the data underpinning one of the keys, you would also need to ensure that the other keys were invalidated to ensure that consumers weren't being served inconsistent data from the cache. Another way to do this would be to create a cache region containing only the interrelated keys.

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