PHP: Is it possible to use APC as a shared cache, perhaps XCache as opcache?

I really understand the general aspects of the APC cache and want to use it in my code (I know how to do this, this is not a problem).

However, I am currently using XCache as opcache and want to continue to do so, as I have the β€œright” one for my specific needs.

The reason I want to use the APC cache as a shared cache is because I am not happy with Pear's PEAR :: Cache_Lite in terms of using it to cache variables, because it stores it on disk, and disk I / O is narrow a place, while there is no RAM, and APC stores the variables in RAM, not in files on disk.

So, does anyone have experience or know if APC can only be configured as a shared cache (the API is called through it in my PHP code, like PEAR :: Cache_Lite), while I support another opcache (in my case, xcache).

Thanks.

+6
php apc xcache
source share
5 answers

Xcache also functions as a shared cache. Like APC. Just use Xcache!

mixed xcache_get(string name) bool xcache_set(string name, mixed value [, int ttl]) bool xcache_isset(string name) bool xcache_unset(string name) bool xcache_unset_by_prefix(string prefix) int xcache_inc(string name [, int value [, int ttl]]) int xcache_dec(string name [, int value [, int ttl]]) 

Here is the API

+5
source share

If apc.cache_by_default if off and apc.filters do not match anything, PHP files will not be cached by APC.

In your configuration:

 apc.cache_by_default = Off 

http://www.php.net/manual/en/apc.configuration.php#ini.apc.cache-by-default

+4
source share

You can use both caches, however both of them overlap in terms of functions. Therefore, ideally, you should configure APC to cache only files, and XCache to OPCache. Please check the following feature comparison :

alt = "Comparison of functions for PHP accelerators such as APC, eAccelerator, XCache, Zend Opcache">

For PHP> = 5.5, APC was discontinued, so you should use XCache or Zend Opcache as the main PHP accelerator for caching.

+1
source share

Runtime configuration options have the following:

apc.optimization 0 "Optimization level: Zero disables the optimizer, and higher values ​​use more aggressive optimizations. Expect very modest speed improvements, this is experimental."

http://www.php.net/manual/en/apc.configuration.php#ini.apc.enabled

0
source share

Having two caches trying to work at the same time would be impossible. They will try to connect to the same system. Choose one.

Now, instead of the standard plug, another technology is used that you do not use:

Technically and in terms of speed, there is not much there, although I saw reports that APC works better with files and especially with methods such as startup (for example, with Zend_loader). APC has easy access (pecl install ...), and this is a "more official" PHP project, and then another caching system.

I used APC for large changes, for these standard opcode, as well as for a significant number of variables with TTL ranging from 30 seconds (how many users are online now), to 24 hours or more (metadata database table).

0
source share

All Articles