NoSQL databases are the hype, with MongoBD and CouchDB on the forefront, while Memcache has found a place in many high load web applications during the past few years. Each of these applications has their own, very specific characteristic. MongoDB finds its usage where single key-value pairs are not sufficient, but adds a slight overhead and complexity with its hash table like multi field storage architecture. CouchDB is an ideal candidate where single key-value pair storage engine is sufficient.
And there is Redis, the new kid on the block. Redis is a high speed storage or cache system, much like Memcache on steroids. Redis writes data into memory, which makes it really fast. And in contrast to Memcache, it writes data periodically to disk depending on the amount of data that has changed. Redis is been said to be able to handle in excess of 10’000 reads/writes per second! Read more »
Troubleshooting memcached is not so transparent as some other technologies, but testing memcached using telnet commands can give us quite some insight on what’s happening under the hood.
Following is a short list of useful commands to inspect a running memcached instance.
How to find the IP address and port to connect:
ps aux | grep memcached will give us the process running memcached, with listening ip address and port. If this command does not yield any results, you likely not running the daemon and need to start it up first.
We can now connect using this info:
telnet 127.0.0.1 11211 (replace your IP address and port)
The following is a list of the most important memcached commands. For a more complete list of supported commands, check out the memcached wiki document. Read more »
I recently installed the memcached daemon on my MacBook Pro, incuding the necessary PHP client for development purposes. I just prefer to work locally instead of using a VM running Linux. And the process is actually quite simple and straight forward. Please note, I have included both clients, the old standard one and the newer PECL extension, because I deal with different applications and also lots of people seems to get confused when they install one version and their memcache classes cannot get instantiated and throw errors. So, if in doubt, just install both.
These are the five (four if you know which extension you want) components needed:
- libevent (requred library for memcached)
- memcached daemon
- libmemcached (required library for the php client)
- php extension (standard)
- php extension (PECL)
Now open your terminal and off we go: Read more »