- # Tar-zxvf./eaccelerator-0.9.5-beta2.tar.bz2
- # Cd eaccelerator-0.9.5-beta2
- # Export PHP_PREFIX = "/usr/local" (import the PHP installation directory to the environment variable. the default value of FreeBSD is/usr/local)
- # $ PHP_PREFIX/bin/phpize
- #./Configure -- enable-eaccelerator = shared -- with-php-config = $ PHP_PREFIX/bin/php-config
- # Make
- # Make install
4. after The INI file is configured and installed, configure the php. ini file. the eAccelerator provides two configuration and call methods. Install in Zend extension mode:
- # Mkdir/tmp/eaccelerator
- # Chmod 777/tmp/eaccelerator
-
5. verify the installation result and access your phpinfo () page through a browser or run php-I to get the php configuration information. if the following information is displayed, the installation is successful. This program makes use of the Zend Scripting Language Engine: Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator Zend Optimizer3.0.1 is also installed on my machine, so the following information is displayed: This program makes use of the Zend Scripting Language Engine: Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies with Zend Optimizer v3.0.1, Copyright (c) 1998-2006, by Zend Technologies if you enable the debug option of eAccelerator, you can see information similar to the following in the log:
- Eaccelerator_lock ("count ");
- Eaccelerator_put ("count", eaccelerator_get ("count") + 1 ));
- ?>
Eaccelerator_unlock ($ key) releases a lock based on $ key Eaccelerator_cache_output ($ key, $ eval_code, $ ttl = 0) caches $ eval_code output $ ttl seconds. (the $ ttl parameter is the same as eacclerator_put parameter.) example:
-
Eaccelerator_cache_result ($ key, $ eval_code, $ ttl = 0) caches $ ttl seconds for the execution result of $ eval_code code (the $ ttl parameter is the same as eacclerator_put parameter). For example:
-
Eaccelerator_cache_page ($ key, $ ttl = 0) caches the entire page for $ 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 (). the parameter is also $ key. 2. the powerful power of eAccelerator in php code accelerated by using eAccelerator: (The code 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 );
- ?>
-
In addition, it is said that eAccelerator support has been integrated in the famous vBulletin 3.60Beta version. A piece of code from vBulletin
//##############
- // EAccelerator
/**
- * Class for fetching and initializing the vBulletin datastore from eAccelerator
- *
- * @ Package vBulletin
- * @ Version $ Revision: 0.1 $
- * @ Date $ Date: 2005/06/12 13:14:18 $
- */
- Class vB_Datastore_eAccelerator extends vB_Datastore
- {
- /**
- * Fetches the contents of the datastore from eAccelerator
- *
- * @ Param array Array of items to fetch from the datastore
- *
- * @ Return void
- */
- Function fetch ($ itemarray)
- {
- If (! Function_exists ('eaccelerator _ get '))
- {
- Trigger_error ("eAccelerator not installed", E_USER_ERROR );
- }
Foreach ($ this-> defaultitems AS $ item)
- {
- $ This-> do_fetch ($ item );
- }
If (is_array ($ itemarray ))
- {
- Foreach ($ itemarray AS $ item)
- {
- $ This-> do_fetch ($ item );
- }
- }
$ This-> check_options ();
// Set the version number variable
- $ This-> registry-> versionnumber = & $ this-> registry-> options ['templateversion'];
- }
/**
- * Fetches the data from shared memory and detects errors
- *
- * @ Param string title of the datastore item
- *
- * @ Return void
- */
- Function do_fetch ($ title)
- {
- $ Data = eaccelerator_get ($ title );
- If ($ data = null)
- {// Appears its not there, lets grab the data, lock the shared memory and put it in
- $ Data = '';
- $ Dataitem = $ this-> dbobject-> query_first ("
- SELECT title, data FROM ". TABLE_PREFIX." datastore
- WHERE title = '". $ this-> dbobject-> escape_string ($ title )."'
- ");
- If (! Empty ($ dataitem ['title'])
- {
- $ Data = & $ dataitem ['data'];
- $ This-> build ($ dataitem ['title'], $ dataitem ['data']);
- }
- }
- $ This-> register ($ title, $ data );
- }
- /**
- * Updates the appropriate cache file
- *
- * @ Param string title of the datastore item
- *
- * @ Return void
- */
- Function build ($ title, $ data)
- {
- If (! Function_exists ('eaccelerator _ put '))
- {
- Trigger_error ("eAccelerator not installed", E_USER_ERROR );
- }
- Eaccelerator_lock ($ title );
- Eaccelerator_put ($ title, $ data );
- Eaccelerator_unlock ($ title );
- }
- }
|