开发者

PHP: Using APC as general cache, XCache as opcache, possible?

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

However, I'm using XCache as opcache now and want to continue to do so since I have it tweaked "just right" for my particular needs.

The reason I want to use APC cache as general cache is that I'm not happy with PEAR::Cache_Lite from Pear in terms of using it for variable caching as it stores it on the disk, and disk I/O is a bottleneck whereas RAM is not and APC stores variables in RAM, not in files on the disk.

So, anyone have any experience or knows if it is possible to setup APC to only run as general cache (being called via it's API in my PHP Code, similarly to that of PEAR::Cach开发者_开发知识库e_Lite) while I maintain another opcache (in my case, xcache).

Thanks.


Xcache works also as a general cache. Just 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


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

In your config:

apc.cache_by_default = Off

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


You can use both caches, however they both overlap in terms of features. So ideally you should configure APC to cache only the files, and XCache as OPCache. Please check the following comparison of features:

PHP: Using APC as general cache, XCache as opcache, possible?

For PHP >= 5.5 APC has been discontinued, therefore you should use XCache or Zend Opcache as your main PHP accelerator for the caching.


The runtime configuration settings have the following:

apc.optimization 0 "The 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


Having the two caches trying to run at the same time would not be possible. They would be attempting to hook into the same system. Choose one.

There now follows the standard plug for the other technology that you don't use:

Technically, and speed-wise, there's not much in it, though I have seen reports that APC does better at including files and particularly with such techniques as autoloading (eg, with Zend_loader). APC does have easy of access (pecl install...), and it's a 'more official' PHP project then the other caching system.

I've used APC to great affect, for that standard opcodes and also for a significant number of variables, with TTLs ranging from 30 seconds (how many people online right now), to 24hrs, or more (database table meta-information).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜