; Change xcache.size to tune the size of the opcode cache
xcache.size = 24M
xcache.shm_scheme = "mmap"
xcache.count = 2
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0
; Change xcache.var_size to adjust the size of variable cache
xcache.var_size = 8M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = "/tmp/xcache"
xcache.coredump_directory = ""
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
[xcache.coverager]
xcache.coverager = On
xcache.coveragedump_directory = ""
示例代码:
<?php
define(TMPDIR, '/tmp');
function load_abc_data()
{
if (xcache_isset("abc_data")) {
return xcache_get("abc_data");
}
// it worth a lock here to avoid useless yet harmful concurrent
// load from any slow backend (backend=mysql here).
$fp = fopen(TMPDIR . "/abc_data.lock", "w");
flock($fp, LOCK_EX);
// check AGAIN after we get the lock
if (xcache_isset("abc_data")) {
fclose($fp);
return xcache_get("abc_data");
}
mysql_query .... and get $data
xcache_set("abc_data", $data, 120); // save for 2 minutes
fclose($fp);
return $data;
}
?>