I've searched all over the web for documentation including on the XCache website.
I'm new to PHP opcode caching and XCache. I'd like an explanation of how XCache works. I know that it stores compiled php code so that it doesn't need to be recompiled everytime. But how does XCache know when php code has been updated and thus the cache is out of date?
How do I know if I need to clear the cache?
Does XCache compile and cache all php code on the server? If so can this be configured?
What are clogs? OOMs? I see large numbers for both of these in the XCache Admin page interface.
In the Code Coverage Viewer... what does Percent mean? Is this the percentage of code that has been cached? Does hits mean the number of lines of compiled code that has been read from cache? Does lines mean the total number of lines of code? What is the ToDo column for? Why are some lines highlighted in red?
I'm using PHP 5.3.2, XCache 1.3.0, and Ubuntu 10.04 if it helps.
optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM.
Based on observations using PHP 5.5.3 and Xcache 3.1.0 this is what I can deduce:
This module deals with two kinds of caching Opcode and Variable.
The Opcode caching is designed to be a simple drop-in. You can't customize how it decides to cache, just how much:
size/count
amount of memoryVariable caching requires using a simple get/set api in your app code. After enabling it using xcache.var_size and xcache.var_count (similar to Opcode settings) you use xcache_set($var1)
and xcache_get($var1)
in your scripts.
The xcache.stat setting controls whether or not to check if the file was modified since it was cached:
In your dev environment it's a good idea to keep it On so you can update and check your code continuously — otherwise you have to flush the cache to see updates to files.
There is a web admin interface which allows you to flush a particular cache. The web admin uses a php api: xcache_clear_cache(…)
.
Since the cache is RAM based anytime the server restarts the cache should be flushed.
Cached items expire according to xcache.ttl
and xcache.var_ttl
which respectively control the number of seconds a cached item lives (0 is indefinite and the default).
The coverager module, aka Code Coverage, is a little mysterious. According to the FeatureList it seems like a diagnostic tool intended to be enabled for temporary administrative/testing situations:
- Coverager + real life testcase framework, this include: [TOSHARE]
- real life testcase framework, a control script with real browser. you have to write the test cases.
- builtin Coverager + its viewer from web, to see how much script you have tested.
- the testcase+Coverager just help you make sure all real life php web applications is running correctly when
- after enabling XCache
- after upgrading php4 to php5
- after upgrading php4/5 to php6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With