Purpose of accelerating PHP code with eaccelerator _php tutorial

Source: Internet
Author: User
Tags echo date php source code phpinfo
Accelerating PHP Code with Eaccelerator
Eaccelerator is really a good thing (its predecessor is Truck-mmcache).
In short, it is a set of caching systems that work with PHP (support PHP5) to exchange data through shared memory or disk files.
It is widely used in PHP source code "code" (not very appropriate called "encryption") and cache php execution of the intermediate code to speed up. The use of the EA installation of the article is a lot and also very detailed, this time I would like to recommend the use of its auxiliary programming cache, it provides a set of APIs as follows:
is a very convenient and stable native cache implementation, currently this part of the design seems to support only the shared memory, so only for the Unix-like OS, Windows is not the blessing.
1. Eaccelerator_put ($key, $value, $ttl =0)
The $value to the $key as the key name in the cache (PHP4 support for the type of image, see the source is not supported in the Zend2), $ttl is the life cycle of this cache, the unit is the second, omit the parameter or specify 0 for unlimited, until the server restarts to empty.
2. Eaccelerator_get ($key)
The return value is NULL if the cache has expired or is not present, based on $key returning the corresponding eaccelerator_put () data from the cache.
3. EACCELERATOR_RM ($key)
To remove a cache from a $key
4. EACCELERATOR_GC ()
Remove cleanup of all expired keys
5. Eaccelerator_lock ($key)
For $key plus locking operations to ensure data synchronization during multi-process multithreaded operations. You need to call Eaccelerator_unlock ($key) to release this lock or to automatically release this lock when the program request ends.
For example:
Eaccelerator_lock ("Count");
Eaccelerator_put ("Count", Eaccelerator_get ("Count") +1));
?>
6. Eaccelerator_unlock ($key)
Release the lock according to the $key
7. Eaccelerator_cache_output ($key, $eval _code, $ttl =0)
$eval the output cache of the _code code $ttl seconds ($ttl parameter same as Eacclerator_put)
For Example:

8. Eaccelerator_cache_result ($key, $eval _code, $ttl =0)
Caches the execution results of the $eval _code code $ttl seconds ($ttl parameter with eacclerator_put), similar to Cache_output
For Example:

9. Eaccelerator_cache_page ($key, $ttl =0)
Caches the current full page $ttl seconds.
For Example:
Eaccelerator_cache_page ($_server[' php_self '). Get= '. Serialize ($_get), 30);
echo Time ();
Phpinfo ();
?>
Eaccelerator_rm_page ($key)
Deletes the cache executed by Eaccelerator_cache_page (), and the parameters are also $key
______________________________________________
(Take a simple example to see its power, note that it may not work in CLI mode!) )
Class Test_cache {
var $pro = ' Hello ';
function Test_cache () {
echo "Object created!
\ 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);
?>
The following is the comments of netizens:
--------------------------------------------------------------------------------
SHOWSA reply to: 2005-12-31 19:51:56win also support! http://www.arnot.info/eaccelerator/
Albatross reply: 2006-01-04 17:17:37 A small bug in the latest version of Eaccelerator 0.9.4-RC1 shows a large number of/var/log/httpd/error_log (warn) broken PIPE:WR ITE Pipe_of_death Error Message workaround Modify the debug.c file-----------------------------------------------/** * Close the debug system. */void Ea_debug_shutdown () {fflush (F_FP);//source statement, file handle not detected when closing file//fclose (F_FP);//Change to if (f_fp! = stderr) fclose (f_fp ); F_FP = NULL; }
Soichiro reply to: 2006-01-10 22:01:21eaccelerator/truck-mmcache It's horrible, I now have two highly loaded systems, one based on Drupal, the other based on PostNuke, After using the Eaccelerator, the drual speed increases 100 times times, the postnuke increases 10 times times, the PostNuke promotion is relatively few because it is very fast.
Wangyih back to: 2006-04-08 10:48:11 and how to use squid ratio
SHOWSA reply: 2006-04-08 23:23:44 How to go with squid to compare ah not the same thing squid is cached page running results if not real-time display, squid certainly strong but the forum and the like, squid will not, with eaccelerator/ Memcache can greatly improve efficiency.
Yarco back at: 2006-04-09 10:00:43 But it is said that there is a conflict with the code of encode. Do not know the current and Zend compatibility?

http://www.bkjia.com/PHPjc/317977.html www.bkjia.com true http://www.bkjia.com/PHPjc/317977.html techarticle using Eaccelerator to accelerate PHP code eaccelerator is really a good thing (its predecessor is Truck-mmcache). In short, it is a set of PHP (support PHP5) operation of the cache system, through ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.