Memcache has more to do with cache lines of distributed objects than with APC or XCache, which stores PHP bytecode in memory, so you don't need to parse it every time. Their main goals are different.
For example, if you had a very intense database query that people often requested, you can cache the resulting object in memcache and then reference it, rather than re-executing this query all the time.
APC and XCache have similar object caching features, but you are limited to the host machine. What if you want 10 different servers to have access to one object without having to repeat the request for each server? You just send them to your memcache server and leave. You still get the advantage if you have only one server, because using memcache will help you scale in the future if you need to branch out to more mailboxes.
The main thing to think about if you think your application needs to be scaled. Memcache has more overhead because you need to use a TCP connection to access it, not just a function call for shared APC / Xcache objects.
However, Memcache has the following advantages:
- Faster than a restart request or restart request.
- Scales to multiple servers.
- It works with many languages, your objects are not blocked only in PHP + APC / Xcache.
- All processes / languages have access to the same objects, so you do not need to worry if your child PHP processes have an empty object cache or not. It may not be so much if you use PHP-FPM.
In most cases, I would recommend caching your objects in memcache, as this is not much more complicated and more flexible in the future.
Keep in mind that this is only relative to object caching. Memcache does NOT have any bytecode or PHP acceleration features, so I will run it side by side with APC or Xcache
Klinky
source share