-3

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
";
Antony
  • 14,900
  • 10
  • 46
  • 74
user3146425
  • 25
  • 2
  • 9

1 Answers1

0

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.

Chris Lam
  • 3,526
  • 13
  • 10
  • 1
    This is a harm advice. Caching doesn't come for free - you bring more moving parts. And it's pity to see it was even checked as an answer. Mysql can manage hundreds of simultaneous requests, whereas with memcached you will experience all the range of issues caused by cache invalidation. Anyway, good luck for you both complicating your code unnecessarily ;-) – zerkms Jul 13 '14 at 04:21
  • The OP author asked for info about object caching. And caching is a very common techniques in large applications nowadays. https://engineering.twitter.com/opensource/projects/twemcache – Chris Lam Jul 13 '14 at 04:25
  • 1
    OP has no idea what it is for and if they *really need* it or not. Please, don't put references to twitter experience in a total newbie question, since it makes little to no sense. To summarize: instead of solving some *real issue* (*if any* exists of course, which I hardly doubt) - you're encouraging using technologies that are redundant in a given case. – zerkms Jul 13 '14 at 04:26