XCache将如何操作呢? 代码覆盖率? 木屐? 奥姆斯?(xcache how does

2019-08-02 21:09发布

我已经搜索所有网站上的文件,包括上了XCache网站 。

我是新来的PHP指令缓存和XCache将。 我想要的了XCache是​​如何工作的解释。 我知道,它存储编译PHP代码,因此它并不需要进行重新编译每次。 但如何做了XCache知道PHP代码已被更新,因此缓存过时?

我怎么知道我是否需要清除缓存?

难道了XCache编译和缓存服务器上的所有 PHP代码? 如果是的话可以这样配置?

什么是木屐? 奥姆斯? 我看到这两个在了XCache管理页面的界面大量涌现。

在代码覆盖浏览器...是什么意思百分比? 这是一个已经被缓存的代码的百分比是多少? 是否命中意味着已经从缓存中读取的编译代码的行数? 是否意味着行的代码行的总数? 什么是待办列? 为什么有些行以红色突出显示?

我使用PHP 5.3.2,1.3.0了XCache和Ubuntu 10.04,如果有帮助。

Answer 1:

Xcache:

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:

Cacher

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:

  • xcache.count setting refers to how many cache threads and correlates to how many processor cores you want to utilize — the idea is that multithreading should be the fastest, but there is no guarantee so experiment yourself
  • As a guideline, valid count values would be 2^n like 1, 2, 4, 8 — 0 will disable the cacher and other values will get rounded to the nearest valid value
  • xcache.size setting refers to the aggregate memory of all cache threads. So, each thread gets roughly size/count amount of memory
  • OOM aka Out of Memory, refers to the event of a cache thread hitting it's maximum size

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

Invalidation

The xcache.stat setting controls whether or not to check if the file was modified since it was cached:

  • When set to On files get checked and re-cached
  • When set to Off skips the check will keep the first cached version as long as the expiration time, which could help performance by limiting disk i/o

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.

Flushing

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.

Expiration

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

Coverager

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


文章来源: xcache how does it work? code coverage? clogs? OOMs?