如何在asp.net mvc中为每个用户使用sqlcachedependency
我在 asp.net mvc (C#) 中有一个应用程序,其中每个用户都有不同的产品,共享一个由用户 ID 分隔的公共表。
我需要为每个用户的产品实现 SqlCacheDependency
。
场景是:假设有两个用户(user1 和 user2),并根据用户 ID 为他们分配产品。
我需要为每个用户使用 SqlCacheDependency
缓存产品,因为他们不会频繁更新/更改它。即使属于 user2 的产品发生更改,我也需要维护 user1 的缓存。
如何根据共享公共表的产品的用户 ID 维护 SqlCacheDependency
?
I have an application in asp.net mvc (C#), in which each user have different products sharing a common table separated by user id.
I need to implement SqlCacheDependency
for each user's products.
The Scenario is: say there are two users (user1 and user2) and products assigned for them based on the user id.
I need to cache the products using SqlCacheDependency
for each user as they wont update/change it frequently. I need to maintain the cache of the user1 even when the products belonging to user2 are changed.
How can i maintain the SqlCacheDependency
based on the User id for products sharing a common table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许需要通过用户id缓存的不是SqlCacheDependency,而是HttpContextCache条目。
这对你有用吗? (我假设
userProducts
是您的DataTable
或List
(视情况而定)。Maybe it's not the SqlCacheDependency that needs to be cached by user id, but the HttpContextCache entry.
Would this work for you? (I'm assuming
userProducts
to be yourDataTable
orList<Product>
as appropriate.