NYCPHP Meetup

NYPHP.org

[nycphp-talk] Eaccelerator

Gary Mort garyamort at gmail.com
Wed Mar 23 12:29:33 EDT 2011


As a followup to my post...  Rolling my own seems that the best solution 
to start with is bcompiler from PECL as it gets rid of all the shared 
memory management options.

However, happily EAccellerator http://eaccelerator.net/ has a fine set 
of configuration options where looking it over, it can be used as the 
basis of my thoughts - by setting the php filesize to 1 byte for shared 
memory, I can force all opcode caching to be used.

It also has a good management API, so I can disable built in management 
and instead hand that process over to a PHP server process to 
periodically clean out old files as well as refreshing files in the 
cache when they change on disk.

I also like the fact that you can disable caching on an individual file 
basis, so if there are files you don't want cached it is easy to fix that.

The one downside is it means no caching for eval.... however that is 
easily fixed by using include instead of eval[using Streams, one can 
define a "variable" stream and then include the variable...

So instead of

$evalphp_query = "select mycode FROM my_code_table where code_select = 
'criteria'";
$result = mysql_query($evalphp_query);
while ($row = mysql_fetch_object($result)) {
     eval($row->mycode);
}

Instead one could run it as:
$evalphp_query = "select mycode, SHA(mycode) as myfilename, 
created_timestamp, changed_timestampe FROM my_code_table where 
code_select = 'criteria'";
$result = mysql_query($evalphp_query);
while ($row = mysql_fetch_object($result)) {
     $pretendfile[$row->myfilename] = $row;
     include('pretendfile://'.$row->myfilename);
}

Register a pretendfile stream handler to provide all the needed file 
data[change date, created date, size, etc] using the $pretendfile array 
and not only can all the old eval'd code now be cached by the opcode 
cacher, but you also gain the ability to use the change timestamp to 
know when to refresh it.

So I'm curious, while this looks good for hacking/having fun with..  for 
"real world use" is eaccelerator currently considered stable?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20110323/63fb0c70/attachment.html>


More information about the talk mailing list