Xcache How does it work? code coverage? shoes? OOMS?

I searched all over the internet for documentation, including the XCache site .

I am new to caching PHP and XCache code. I would like to explain how XCache works. I know that it stores compiled PHP code, so it does not need to be recompiled every time. But how does XCache know when the php code is updated, and therefore the cache is out of date?

How do I know whether to clear the cache?

Does XCache compile and cache all PHP code on the server? If it can be customized?

What is a clog? OOMS? I see large numbers for both of them in the interface of the XCache administration page.

In the code viewer ... what does percentage mean? Is this the percentage of code that has been cached? Does the number of hits have the number of lines of compiled code that was read from the cache? Do lines mean the total number of lines of code? What is the ToDo column for? Why are some lines highlighted in red?

I am using PHP 5.3.2, XCache 1.3.0 and Ubuntu 10.04 if this helps.

+6
source share
1 answer

Xcache :

optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts in shm (RAM) and using the compiled version directly from RAM.

Based on observations using PHP 5.5.3 and Xcache 3.1.0 , I can do this:

Cacher

This module covers two types of caching Opcode and Variable .

Opcode caching is designed for easy migration. You cannot configure how it decides to cache how much:

  • xcache.count indicates how many cache threads and correlates with the number of processor cores that you want to use - the idea is that multithreading should be the fastest, but there is no guarantee, so experiment yourself.
  • As a guideline, the actual values ​​of the account will be 2 ^ n, as 1, 2, 4, 8 - 0, disables cacher, and other values ​​are rounded to the nearest real value
  • xcache.size points to the aggregate memory of all cache threads. Thus, each thread receives approximately size/count memory
  • OOM aka Out of Memory , refers to the event when the cache stream reaches its maximum size

For variable caching, you need to use a simple get / set api in the application code. After you enable it using xcache.var_size and xcache.var_count (similar to the opcode settings), you use xcache_set($var1) and xcache_get($var1) in your scripts.

lost

The xcache.stat parameter determines whether to check whether the file has been modified since it was cached:

  • When set to On , files are checked and overwritten.
  • When set to Off. , the pass will remain in the first cached version until the expiration time, which can help performance by limiting disk I / O

In your development environment, it is recommended to store On so that you can constantly update and check your code, otherwise you must clear the cache to see file updates.

Flushing

There is a web admin interface that allows you to clear a specific cache. The web administrator uses the php api: xcache_clear_cache(…) .

Since the cache is RAM, at any time when the server restarts the cache, it must be reset.

Really

Cached objects expire according to xcache.ttl and xcache.var_ttl , which respectively control the number of seconds that a cached item is stored (0 is undefined and the default value).

Corager

The cover module, otherwise called Code Coverage, is a little cryptic. According to FeatureList , this is like a diagnostic tool that should be enabled for temporary administrative / test situations:

  • Coverager + real test case environment, including: [TOSHARE]
    • realcase testcase framework, a script control with a real browser. you need to write test cases.
    • built-in Coverager + its viewer from the Internet to find out how many script you tested.
  • testcase + Coverager just helps you make sure that all real php web applications work correctly when
    • after turning on XCache
    • after upgrading php4 to php5
    • after upgrading php4 / 5 to php6
+7
source

All Articles