PHP缓存技术

发布于 2024-11-06 01:09:07 字数 449 浏览 0 评论 0原文

您好,这实际上更像是一个信息请求。

我目前正在开发一个相当大的事件列表网站,并开始考虑对所使用的数据集进行一些缓存。

这周我一直在研究 APC,并在测试过程中看到了一些真正的改进,但是我正在努力思考的是尝试缓存经常更改的数据时所需的最佳实践和技术。

例如,假设用户点击主页,默认情况下会显示最近发生的 10 个事件,并且如果该用户登录,则这些事件是特定于位置的。在处理登录状态和频繁更改的数据时,是否可以部署某种缓存系统,该系统当前允许用户“显示更多事件:这是一个从数据库中提取额外结果的ajax请求。

我还没有”并没有真正找到任何东西,因为我不确定要搜索什么,但我真的很想知道用于高级缓存系统的技术,这些技术特别处理变化的数据和特定于用户的数据,

我的意思是它值得吗 ?是交易时的其他性能助推器吗?符合这种标准?

任何有关此的文章或提示和信息将不胜感激!如果需要任何其他信息,请告诉我!

Hi this is more of an information request really.

I'm currently working on a pretty large event listing website and have started thinking about some caching for the data sets being used.

I have been messing with APC this week and have seen some real improvements during testing however what I'm struggling to get my head around is best practices and techniques required when trying to cache data that changes frequently.

Say for example the user hits the home page, this by default displays the latest 10 events happening and if that user is logged in those events are location specific. Is it possible to deploy some kind of caching system when dealing with logged in states and data that changes frequently, the system currently allows the user to "show more events: which is an ajax request to pull extra results from the db.

I haven't really found anything on this as I'm not sure what to search for but I'm really interested to know the techniques used for advanced caching systems that deal especially with data that changes and data specific to users?

I mean is it even worth it? are the other performance boosters when dealing with this sort of criteria?

Any articles or tips and info on this will be greatly appreciated!! Please let me know if any other info is required!!

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

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

发布评论

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

评论(3

杯别 2024-11-13 01:09:08

您的基本解决方案是:

  • 文件缓存
  • memcached/redis
  • APC

每个用于略有不同的目标。

当您可以预渲染文件或文件的一部分时,通常会使用文件缓存。它用于模板解决方案、部分视图 (mvc)、CSS 框架。之类的东西。

Memcached 和 Redis 或多或少是相同的,只是 Redis 更面向 noSQL。它们用于分布式缓存(多个服务器,相同的缓存数据)和存储会话(如果您有网络服务器集群)。

APC 有利于两件事:操作码缓存和数据缓存。比 memcached 更快,但单独适用于每个服务器。


底线是:在一个巨大的项目中,您将使用所有这些。每个人都有不同的任务。

Your basic solutions are:

  • file cache
  • memcached/redis
  • APC

Each used for slightly different goal.

File cache is usually something that you utilize when you can pre-render files or parts of them. It is used in templating solutions, partial views (mvc), css frameworks. That sort of stuff.

Memcached and redis are both more or less equal, except redis is more of a noSQL oriented thing. They are used for distributed cache ( multiple servers , same cached data ) and for storing the sessions, if you have cluster of webservers.

APC is good for two things: opcode cache and data cache. Faster then memcached, but works for each server separately.


Bottom line is : in a huge project you will use all of them. Each for a different task.

如日中天 2024-11-13 01:09:08

因此,您可以使用操作码缓存,通过将已编译的 PHP 文件保存在缓存中来加快速度。

然后,您可以使用数据缓存,在其中保存需要时间才能获取从 SQL 查询构建的数据的变量或对象。

然后,您可以使用输出缓存,将整个网页块保存在文件中,并输出这些文件,而不是在每个请求上构建该网页块。

我曾经写过一篇关于如何进行输出缓存的博客文章:

http://www.spotlesswebdesign。 com/blog.php?id=17

如果它是特定于位置的,并且有十亿个位置,那么假设您有大量磁盘空间,您最好的选择可能是输出缓存,但您将不得不使用您的头什么是最好,因为在如何最好地应用缓存方面,每种情况都非常不同。

So you have opcode caching, which speeds things up by saving already compiled PHP files in cache.

Then you have data caching, where you save variables or objects that take time to get like data built from SQL queries.

Then you have output caching, which is where you save entire blocks of your webpages in files, and output those files instead of building that block of your webpage on each request.

I once wrote a blog post about how to do output caching:

http://www.spotlesswebdesign.com/blog.php?id=17

If it's location specific, and there are a billion locations, your best bet is probably output caching assuming you have a lot of disc space, but you will have to use your head for what is best, as each situation is very different when it comes to how best to apply caching.

泅渡 2024-11-13 01:09:08

如果操作正确,使用 memcached 或类似的解决方案可以极大地提高网站性能。通过直接更改缓存的数据而不是从数据库重新水化它,您可以完全绕过数据库来获取不需要保存或可以轻松重建的数据。由于数据库通常是 Web 应用程序中最关键的组件,因此您可以减轻它的任何负载都是额外的好处。

另一方面,确保数据库查询尽可能轻量和高效将对性能产生比大多数缓存调整更大的影响。

If done correctly, using memcached or similar solutions can give huge boosts to site performance. By altering the cached data directly instead of rehydrating it from the database you can bypass the database entirely for data that either doesn't need to be saved or can be trivially rebuilt. Since the database is often the most critical component in web applications, any load you can take off it is a bonus.

On the other hand, making sure your database queries are as light and efficient as possible will have a much larger impact on performance than most cache tweaks.

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