Memcache Vs. Memcached

PhpMemcached

Php Problem Overview


> Possible Duplicate:
> Using Memcache vs Memcached with PHP

Someone can explain me the difference between Memcache and Memcached in PHP environment? What are the advantages of one over the other? Can you also suggest the criteria used to choose between one or the other?

Php Solutions


Solution 1 - Php

They are not identical. Memcache is older but it has some limitations. I was using just fine in my application until I realized you can't store literal FALSE in cache. Value FALSE returned from the cache is the same as FALSE returned when a value is not found in the cache. There is no way to check which is which. Memcached has additional method (among others) Memcached::getResultCode that will tell you whether key was found.

Because of this limitation I switched to storing empty arrays instead of FALSE in cache. I am still using Memcache, but I just wanted to put this info out there for people who are deciding.

Solution 2 - Php

(PartlyStolen from ServerFault)

I think that both are functionally the same, but they simply have different authors, and the one is simply named more appropriately than the other.


Here is a quick backgrounder in naming conventions (for those unfamiliar), which explains the frustration by the question asker: For many *nix applications, the piece that does the backend work is called a "daemon" (think "service" in Windows-land), while the interface or client application is what you use to control or access the daemon. The daemon is most often named the same as the client, with the letter "d" appended to it. For example "imap" would be a client that connects to the "imapd" daemon.

This naming convention is clearly being adhered to by memcache when you read the introduction to the memcache module (notice the distinction between memcache and memcached in this excerpt):

> Memcache module provides handy > procedural and object oriented > interface to memcached, highly > effective caching daemon, which was > especially designed to decrease > database load in dynamic web > applications. > > The Memcache module also provides a > session handler (memcache). > > More information about memcached can > be found at » > http://www.danga.com/memcached/.

The frustration here is caused by the author of the PHP extension which was badly named memcached, since it shares the same name as the actual daemon called memcached. Notice also that in the introduction to memcached (the php module), it makes mention of libmemcached, which is the shared library (or API) that is used by the module to access the memcached daemon:

> memcached is a high-performance, > distributed memory object caching > system, generic in nature, but > intended for use in speeding up > dynamic web applications by > alleviating database load. > > This extension uses libmemcached > library to provide API for > communicating with memcached servers. > It also provides a session handler > (memcached). > > Information about libmemcached can be > found at » > http://tangent.org/552/libmemcached.html.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLuca BernardiView Question on Stackoverflow
Solution 1 - PhpMike StarovView Answer on Stackoverflow
Solution 2 - PhpMezView Answer on Stackoverflow