用PHP缓存数据 [英] Caching data in PHP

查看:72
本文介绍了用PHP缓存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP开发一个站点,该站点具有一些复杂的SQL查询,并且我想实现一种缓存功能以减少数据库的负载。

I'm developing a site in PHP which has some complex SQL queries and I would like to implement a caching feature to reduce the load on the database.

我只是想知道直接将HTML写入文件或读取HTML还是创建带有分隔符的YAML文件来分隔记录然后包装它会更好在HTML中具有功能?

I'm just wondering would it be better to write and read HTML directly to a file or perhaps create something like a YAML file with a delimiter to separate records then wrap it in HTML with a function?

我的想法是,这将允许将用户选项(例如,要显示的记录数)应用于请求。

My thinking is that this would allow user options (for example, number of records to display) to be applied to the request.

任何建议/建议都会得到赞赏。

Any advice / suggestions appreciated.

谢谢。

推荐答案

使用以下任意一种来缓存后端:

Use any of these for caching backends:

  • http://php.net/manual/en/book.apc.php
  • http://memcached.org/
  • http://xcache.lighttpd.net/

并使用Zend_Cache为它们建立统一的接口

and use Zend_Cache for a unified interface to them

  • http://framework.zend.com/manual/en/zend.cache.html

是使用全页缓存还是部分缓存取决于您的特定用例。通常,您的应用程序将两者混合使用。

Whether to use full page caching or partial caching depends on your specific UseCases. Usually, your application will have a mix of both.

这篇关于用PHP缓存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆