- #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 into the environment variable, freebsd default is/usr/local)
- # $PHP _prefix/bin/phpize
- #./configure--enable-eaccelerator=shared--with-php-config= $PHP _prefix/bin/php-config
- #make
- #make Install
Copy Code4, INI file configuration installation is complete, the following start to configure the php.ini file, Eaccelerator provides two ways to configure and call, respectively, as follows. Install as Zend extension mode:
- #mkdir/tmp/eaccelerator
- #chmod 777/tmp/eaccelerator
Copy Code5, verify the installation results through the browser to access your phpinfo () page or run php-i to get the PHP configuration information, if you see a message similar to the following indicates that the installation was 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 I have also installed Zend on my machine Optimizer3.0.1, so see the following information: This program makes use of the Zend Scripting Language engine:zend Engine v2.1.0, Copyright (c) 19 98-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-20 , by Zend Technologies if you turn on the debug option for Eaccelerator, you can see information like the following from the log
- Eaccelerator_lock ("Count");
- Eaccelerator_put ("Count", Eaccelerator_get ("Count") +1));
- ?>
Copy CodeEaccelerator_unlock ($key) Release lock according to $key Eaccelerator_cache_output ($key, $eval _code, $ttl =0) will $eval the output cache of the _code code $ttl seconds, ($ttl parameters with Eacclerator_put) such as:
-
Copy CodeEaccelerator_cache_result ($key, $eval _code, $ttl =0) caches the execution results of the $eval _code code $ttl seconds, ($ttl parameter is the same as Eacclerator_put), similar to cache_ Output for example:
-
Copy CodeEaccelerator_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 ();
- ?>
Copy CodeEaccelerator_rm_page ($key) deletes the cache executed by Eaccelerator_cache_page (), and the parameters are also $key 2, PHP code using eaccelerator accelerated test eaccelerator Powerful: (This code may not be valid 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);
- ?>
Copy CodeIn addition, it is said that the support for Eaccelerator has been integrated in the famous vbulletin 3.60Beta version. A piece of code from vbulletin inside
// ##############
- 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 the 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);
- }
- }
Copy Code |