PHP加速 eAccelerator配置和使用指南(3)

<?php
classtest_cache{
 
var$pro = 'hello';

 
functiontest_cache(){
    
echo"Object Created!<br>\n";
 
}
 
functionfunc(){
    
echo', the world!';
 
}
 
functionnow($t){
    
echodate('Y-m-d H:i:s', $t);
 
}
}

$tt = eaccelerator_get("test_tt");
if(!$tt)
{
 
$tt = newtest_cache;
 
eaccelerator_put("test_tt", $tt);
 
echo"no cached!<br>\n";
}
else{
 
echo"cached<br>\n";
}

echo$tt->pro;
$tt->func();
$tt->now(time() + 86400);
?>

另外,据说在著名的vBulletin 3.60Beta版里面已经集成了对eAccelerator的支持,下面是一段来自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);
}
}


四、附录和参考资料
eAccelerator 官方网站 :
Websites using eAccelerator ?

(2006/03/03) Advanced Financial Network, serves over 7 million page hits per day.
(2005/01/29) Andrew Hutchings - Linux Guru - Just a quick message to say we are now using eaccelerator as a replacement for mmcache on 2 of our 3 node round robin clusters, 2.5million hits per day. We will be doubling this in the next few week, as well as implementing new clusters.
(2005/02/07) Denny Reeh - System Developer - The e/t/s didactic media provides an elearning server (Distance Learning System) written in PHP. We are hosting the systems for our customers mainly by ourself. So we have 5 live-servers (freebsd, apache2, php4, eaccelerator) with 5.5 million hits per month. First without eAccelerator we should have installed more servers for good performance and secondly we improve the customer convenience by quartering the medium response time of a script.
(2005/08/03) Gorgoyle.com is Yet Another Debian Personal Server with just a few lost Internet wanderers passing by, powered by a glorious Celeron 433 that needed some fresh air… With eAccelerator the result is quite impressive: users say the server speed is now 10000% higher (no joke!) So thank you all and keep up the good work!!! Server: eAccelerator 0.9.5 beta 1 Apache/2.0.55 (Debian) mod_python/3.1.3 Python/2.3.5 PHP/4.4.2-1 mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2
(2005/05/24) The Mafia-Incorporated is a succesfull Browser game with around 2.500.000 page impressions each day and over 5000 users. Server: PHP Version 4.3.10-9, eAccelerator 0.9.2a, Debian , Apache 2.0.53
(2005/01/07) An other game oriented french website with 6 000 000 pageloads monthly. is a full PHP5 oo development. Theses websites are running under freebsd / apache 1.3 / php 5.0.3 / eaccelerator 0.9.2
(2005/12/09) Markus Ostertag - Movie Maze is a large german online-magazine with trailer, wallpaper, reviews, news and much more. Currently we use three servers (Suse & Debian with Apache 2, PHP4) with eAccelerator and provide more than 3TB data to ~1 Mio. users each month.
(2005/01/04) The Slovenian National RTV Station and its news/misc portal with forums. Over 3500 users and more than 37000 forum messages in a year. Two round-robin servers for the masses, and an administrator server. 6 000 000 pageloads monthly.
(2006/03/28) A site about mushrooms and mycology, serving 20,000,000 pages per month. Web and database server are identical dual 64-bit Xeons with 4GB and SCSI RAID5 running Gentoo. eAccelerator help keep our page generation time under .1 second!

(2005/04/25) SourceForge.net is the world's largest Open Source software development web site, hosting more than 100,000 projects and over 1,000,000 registered users with a centralized resource for managing projects, issues, communications, and code. SourceForge.net has the largest repository of Open Source code and applications available on the Internet, and hosts more Open Source development products than any other site or network worldwide. SourceForge.net provides a wide variety of services to projects we host, and to the Open Source community. eAccelerator is used on the webserver cluster for their frontpage.
Companies offering hosting with eAccelerator enabled ?

(2006/04/29) Offering webhosting w/ Apache/2.0.55, PHP 5.0.5, and eAccelerator 0.9.5 beta1 on Gentoo Linux servers. Also a provider of quality Virtual Private Server (VPS) hosting, including 32 and 64-bit platforms. Most VPS images have a pre-installed LAMP environment w/ eAccelerator installed and configured.
A student organisation which provides shell and internet services for students at very cheap prices.

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/14a73b7740cff643fdee3f8cb87ad573.html