It seems that PHP has two memcached libraries named memcache and memcached. What is the difference and how do you know which one to use? Is one outdated? It seems that memcached offers more methods so I would assume that means it has had the most development - but it also seems to require external C/C++ libraries so I'm not sure if I can install it.
It seems that memcache has been around longer, does not require additional libraries, and has pre-compiled binaries for even windows! I would think that it would be the better choice for now. However, being new to memcached (server) I'm not sure if there is some super important features in memcached (php) that make it worth the extra trouble.
They both have very basic difference while storing value. Memcache mostly considers every value as string whereas Memcached stores it value's original type.
Memcached can serve cached items in less than a millisecond, and enables you to easily and cost effectively scale for higher loads. Memcached is popular for database query results caching, session caching, web page caching, API caching, and caching of objects such as images, files, and metadata.
Redis uses a single core and shows better performance than Memcached in storing small datasets when measured in terms of cores. Memcached implements a multi-threaded architecture by utilizing multiple cores. Therefore, for storing larger datasets, Memcached can perform better than Redis.
Requested data is now forwarded to the client-server and, at the same time, the Memcache index is updated with these latest values: the cache is now ready to be used in the future (see step 3). Typically, Memcached is set up via different Memcached servers and clients, which help to distribute the load of the requests.
Memcached is an in-memory key-value store for small arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. This system stores key-values data for string and objects, such as: Memcached uses a client-server architecture based on four components:
Since Memcached is solely relying on RAM, it doesn’t require too many CPU resources. Several web hosting services come with pre-installed Memcached system on their cloud servers: you can find some examples on A2 Hosting, Cloudways or Siteground.
The first condition to use Memcached on your WordPress site is that your hosting server has it installed. The second condition is that your web application can support Memcached. Since Memcached is solely relying on RAM, it doesn’t require too many CPU resources.
Memcached client library was just recently released as stable. It is being used by digg ( was developed for digg by Andrei Zmievski, now no longer with digg) and implements much more of the memcached protocol than the older memcache client. The most important features that memcached has are:
All of this points were enough for me to switch to the newest client, and can tell you that it works like a charm. There is that external dependency on the libmemcached library, but have managed to install it nonetheless on Ubuntu and Mac OSX, so no problems there so far.
If you decide to update to the newer library, I suggest you update to the latest server version as well as it has some nice features as well. You will need to install libevent for it to compile, but on Ubuntu it wasn't much trouble.
I haven't seen any frameworks pick up the new memcached client thus far (although I don't keep track of them), but I presume Zend will get on board shortly.
Zend Framework 2 has an adapter for Memcached which can be found here
When using Windows, the comparison is cut short: memcache
appears to be the only client available.
Memcached is a newer API, it also provides memcached as a session provider which could be great if you have a farm of server.
After the version is still really low 0.2 but I have used both and I didn't encounter major problem, so I would go to memcached since it's new.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With