Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

apc

xcache

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.

like image 893
Adergaard Avatar asked Oct 19 '09 08:10

Adergaard


People also ask

How to enable OPcache in PHP?

OPcache can only be compiled as a shared extension. If you have disabled the building of default extensions with --disable-all, you must compile PHP with the --enable-opcache option for OPcache to be available. Once compiled, you can use the zend_extension configuration directive to load the OPcache extension into PHP.

What is PHP OPcache?

OPcache is a caching engine built into PHP. When enabled, it dramatically increases the performance of websites that utilize PHP. From php.net: OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.

What is APCu PHP?

APCu is an in-memory key-value store for PHP. Keys are of type string and values can be any PHP variables. APCu only supports userland caching of variables. APCu is APC stripped of opcode caching.


1 Answers

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

like image 116
Nir Avatar answered Nov 12 '22 04:11

Nir