tags:

views:

570

answers:

4

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::Cache_Lite) while I maintain another opcache (in my case, xcache).

Thanks.

A: 

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

cballou
+3  A: 

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

Nir
A: 

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

Ole J. Helgesen
A: 

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).

Alister Bulman