phpmysqlsqlitedatabase-caching

Caching with php file


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.

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
";

Solution

  • 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.

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