缓存来自 SqlProfileProvider 的配置文件 -- ProfileManager.GetAllProfiles 结果

发布于 2024-08-09 19:45:05 字数 443 浏览 4 评论 0原文

我在我的一个网站上使用 SqlProfileProvider,在一个页面中我需要获取配置文件的整个列表(它是一个 Intranet)。

我使用的方法是 ProfileManager.GetAllProfiles()。问题是它的性能非常糟糕,并且大大减慢了网站的速度。

因此,我正在考虑将应用程序范围中方法调用的结果缓存为数据表(这样我也可以对其进行过滤/搜索)。

我的问题是我有几个服务器运行这个网络应用程序,我希望缓存保持同步。我开始使用 memcached,但由于一些问题而推迟了(因此又重新思考应用程序范围内的缓存)。

所以,我的问题是:

  • 将包含配置文件的 DataTable 存储在 Application 对象中是否有效?或者,是否可以将对象存储在缓存中并使它们可供所有客户端/浏览器使用?
  • 是否可以向此缓存添加 (SQL) 缓存依赖项?

I'm using the SqlProfileProvider on one of my websites and in one page I need to fetch the whole list of profiles (it is an intranet).

The method that I use is the ProfileManager.GetAllProfiles(). The problem is that its performance is really bad and it slows down the website considerably.

Therefore, I was thinking of caching the result of the method call in the Application scope as a DataTable (so I could filter/search on it as well).

My problem is that I have several servers running this webapp, and I would like the cache to be in sync. I started using memcached but I was put off by some problems (hence going back to thinking in caching in the Application scope).

So, here are my questions:

  • Would it be efficient to store the DataTable containing the profiles in the Application object? Or, is it possible to store objects in the Cache and have them available for all clients/browsers?
  • Is it possible to add a (SQL) Cache Depedency to this cache?

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

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

发布评论

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

评论(1

橙幽之幻 2024-08-16 19:45:05

您可以缓存网页的部分,具体取决于列表将配置文件放入用户控件并将其标记为可缓存。还可以定义 SqlCacheDependency 缓存策略过期。至于缓存位置,场中的每个 Web 服务器都会在内存中拥有自己的版本,但使用缓存过期将确保该版本不会与数据库中的数据不同步。

页面或片段缓存是最有效的缓存技术,因为与缓存模型(DataTable 或其他)相反,您无需付出 HTML 渲染的代价。

You could cache portions of the web page which will depend on the list of profiles by putting them in a user control and marking it as cacheable. SqlCacheDependency cache policy expiration could be defined as well. As for the cache location, every web server in the farm will have it's own version in memory but using cache expiration will make sure that this version is not out of sync with the data in the DB.

Page or fragment caching is the most effective caching technique because contrary to caching your model (a DataTable or whatever) you don't pay the price of HTML rendering.

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