Use eAccelerator to accelerate PHP code. EAccelerator is really a good thing (its predecessor is truck-mmcache ). To put it simply, it is a cache system that works with PHP (supports PHP5). eAccelerator is really a good thing (its predecessor is truck-mmcache) through shared memory or disk files ).
Simply put, it is a cache system that works with PHP (supporting PHP5) and exchanges data through shared memory or disk files.
It is widely used in PHP source code "encoding" (hereinafter referred to as "encryption") and cache the intermediate code executed by PHP to accelerate. There have been a lot of articles on eA installation and use, and they are also very detailed. this time I would like to recommend using it to assist program design caching. It provides a set of APIs as follows:
It is a very convenient and stable local cache implementation method. Currently, this part of the design only supports shared memory, so it can only be used for Unix-Like OS, windows is no better off.
1. eaccelerator_put ($ key, $ value, $ ttl = 0)
Save $ value to the cache with $ key as the key name (the object type is supported in php4, and the source code does not seem to be supported in zend2). $ ttl is the cache lifecycle, the unit is seconds. If this parameter is omitted or 0 is specified, the operation is not limited until the server is restarted and cleared.
2. eaccelerator_get ($ key)
According to $ key, the corresponding eaccelerator_put () stored data is returned from the cache. if the cache has expired or does not exist, the return value is NULL.
3. eaccelerator_rm ($ key)
Remove cache based on $ key
4. eaccelerator_gc ()
Remove all expired keys
5. eaccelerator_lock ($ key)
Add a lock operation to $ key to ensure data synchronization during multi-process and multi-thread operations. You need to call eaccelerator_unlock ($ key) to release the lock or wait until the end of the program request to automatically release the lock.
For example:
Eaccelerator_lock ("count ");
Eaccelerator_put ("count", eaccelerator_get ("count") + 1 ));
?>
6. eaccelerator_unlock ($ key)
Release lock based on $ key
7. eaccelerator_cache_output ($ key, $ eval_code, $ ttl = 0)
Cache the $ eval_code output for $ ttl seconds (the $ ttl parameter is the same as eacclerator_put parameter)
For Example:
8. eaccelerator_cache_result ($ key, $ eval_code, $ ttl = 0)
Cache the execution result of $ eval_code code for $ ttl seconds (the $ ttl parameter is the same as eacclerator_put), similar to cache_output
For Example:
9. eaccelerator_cache_page ($ key, $ ttl = 0)
Cache the entire page for $ ttl seconds.
For Example:
Eaccelerator_cache_page ($ _ SERVER ['php _ SELF '].'? GET = '. serialize ($ _ GET), 30 );
Echo time ();
Phpinfo ();
?>
10. eaccelerator_rm_page ($ key)
Deletes the cache executed by eaccelerator_cache_page (). the parameter is also $ key.
______________________________________________
(For a simple example, check its power. Note that it may not work in cli mode !)
/N ";} function func () {echo ', the world! ';} Function now ($ t) {echo date ('Y-m-d H: I: S', $ t );}} $ tt = eaccelerator_get ("test_tt"); if (! $ Tt) {$ tt = new test_cache; eaccelerator_put ("test_tt", $ tt); echo "no cached!
/N ";} else {echo" cached
/N ";}echo $ tt-> pro; $ tt-> func (); $ tt-> now (time () + 86400);?>
Callback (its predecessor is truck-mmcache ). To put it simply, it is a cache system that works with PHP (supporting PHP5), by sharing memory or disk files...