-
-
eaccelerator_lock(“count”);
- eaccelerator_put(“count”,eaccelerator_get(“count”)+1));
- ?>
复制代码
eaccelerator_unlock($key)
根据 $key 释放锁
eaccelerator_cache_output($key, $eval_code, $ttl=0)
将 $eval_code 代码的输出缓存 $ttl 秒,($ttl参数同 eacclerator_put)
例如:
eaccelerator_cache_result($key, $eval_code, $ttl=0)
将 $eval_code 代码的执行结果缓存 $ttl 秒,($ttl参数同 eacclerator_put),类似 cache_output
例如:
eaccelerator_cache_page($key, $ttl=0)
将当前整页缓存 $ttl 秒。
例如:
-
-
eaccelerator_cache_page($_SERVER['PHP_SELF'].'?GET='.serialize($_GET),30);
- echo time();
- phpinfo();
- ?>
复制代码
eaccelerator_rm_page($key)
删除由 eaccelerator_cache_page() 执行的缓存,参数也是 $key
2、php代码中使用eAccelerator加速
另外,在PHPCMS里面已经集成了对eAccelerator的支持,下面是一段来自PHPCMS里面的代码
-
-
class cache
- {
- function __construct()
- {
- }
function cache()
- {
- $this->__construct();
- }
function get($name)
- {
- return eaccelerator_get($name);
- }
function set($name, $value, $ttl = 0)
- {
- eaccelerator_lock($name);
- return eaccelerator_put($name, $value, $ttl);
- }
function rm($name)
- {
- return eaccelerator_rm($name);
- }
function clear()
- {
- return eaccelerator_gc();
- }
- }
-
复制代码
|