用PHP文件缓存 [英] Caching with php file

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

问题描述

我正在用简单的代码创建一个php脚本.我对缓存不了解.但是听说有对象缓存,数据库缓存可以缩短加载时间.

I am creating a php script with simple coding. I don't have much knowledge about caching. But have heard that there are object caching, Database Caching which will improve load time.

例如,我有一个示例php查询,如何启用数据库缓存,还请告诉我一些有关对象缓存的基础知识.

e.g., I have a sample php query, how can I enable database caching and please also tell me some basics about object caching.

$test="
SELECT *, 
       Sum(sellprice*quantity) + tips AS amount, 
       receiptdetails.name            AS personname 
FROM   cart, 
       cartproduct, 
       receiptdetails, 
       receipt, 
       product 
WHERE  cart.ID = cartproduct.cartid 
       AND receiptdetails.cartid = cart.ID 
       AND receipt.cartid = cart.ID 
       AND product.ID = cartproduct.productid 
GROUP  BY cart.ID
";

推荐答案

最流行的方法是将 Memcached 用于缓存.基本上,它只是一个将键值存储在RAM中的键值存储引擎.您的应用程序可以利用它来缓存值,以减少每次查询数据库的需求.

The most popular way is to use Memcached for caching. Basically it is just a key-value storage engine that cache values in RAM. Your application can make use of it to cache values to reduce the needs for querying DB every time.

您可以查看 PHP的Memcached扩展带有Memcached的PHP.

You can take a look at the PHP's Memcached extension on how to use PHP with Memcached.

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

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