Is it necessary to hit our database server for each query we are executing ?

Can I reduce the no of requests to my database server ?

The one quick solution to all the above questions is, the memcache.

In short, memcache is a key-value pair database and it's stored in system memory... yes, it using a portion of the system RAM !

How it works ?

It stores the query string as the key and and the query results as it's value.

Still confused ?

Imagine you are executing the selection query in database server.

Take the md5 hash of the query string you just executed and mark it as the key and the results set as the value for this key.

Update this key-value pair in memcache server.
Next time executing any query , convert your string into md5 hash and search for the memcache server for any matching results.

If it's matches, then why do you want to disturb your database server again !

So memcache provides a volatile memory to store the most frequently used query strings/results and an easy way to retrive the stored data without disturbing your database server

That's it !