Force caching of files during update

44 views
Skip to first unread message

Anders Åstrand

unread,
Sep 16, 2010, 8:52:47 AM9/16/10
to eaccel...@googlegroups.com
Hello everyone.

I'm pretty new to eAccelerator, so please excuse me if the answer to my
questions are obvious.

I have a website on which I would like to be able to publish small
changes without taking it offline.

My thought is that for small updates (like less then 20 php files or so
changed) I could do the following:

1) force eAccelerator to cache the old versions of the file to the disk
cache
2) update the php files using rsync
3) flush the eAccelerator disk cache

Do you guys think this would work without borking up requests done while
the update is in progress?

How would I accomplish step 1?

How would I make sure eAccelerator, apache
or php won't try to access any of the updated files while 2 is in
progress?

How do I make sure eAccelerator doesn't try to access the disk cache
during 3?

If the accelerator would have to be disabled during some of these steps
that's all cool, aslong as the website is still working.

Thanks for any help or pointers in the right direction!

Regards,
Anders

Jani Ollikainen

unread,
Sep 16, 2010, 9:34:47 AM9/16/10
to eaccel...@googlegroups.com
On 16.09.2010 15:52, Anders �strand wrote:
> How would I accomplish step 1?

eaccelerator.check_mtime = 0

> How would I make sure eAccelerator, apache
> or php won't try to access any of the updated files while 2 is in
> progress?
> How do I make sure eAccelerator doesn't try to access the disk cache
> during 3?

Only idea that comes to my minds really archiving that is to
play with LVM snapshots.

--
Yhteisty�terveisin,
Jani Ollikainen @ Pronetko Networks Oy

Anders Åstrand

unread,
Sep 16, 2010, 9:41:18 AM9/16/10
to eaccelerator
On Sep 16, 3:34 pm, Jani Ollikainen <jani.ollikai...@pronetko.fi>
wrote:
> On 16.09.2010 15:52, Anders strand wrote:
>
> > How would I accomplish step 1?
>
> eaccelerator.check_mtime = 0
>

Would that force caching of scripts that hadn't been requested by the
webserver aswell?

> > How would I make sure eAccelerator, apache
> > or php won't try to access any of the updated files while 2 is in
> > progress?
>

Aslong as the scripts are in the cache they shouldn't be accessed,
right? I just need to be 100% sure.

>  > How do I make sure eAccelerator doesn't try to access the disk cache
>  > during 3?
>
> Only idea that comes to my minds really archiving that is to
> play with LVM snapshots.
>

What I would like is to disable eaccelerator (so that apache reads the
real php-files), wait for any requests involving eaccelerator to
complete, then clear the cache and re-enable it.

Is this not possible with eaccelerator? Does anyone with insight into
the inner workings of eaccelerator know if it would be hard to add to
my own version?

Jani Ollikainen

unread,
Sep 16, 2010, 9:53:32 AM9/16/10
to eaccel...@googlegroups.com
On 16.09.2010 16:41, Anders �strand wrote:
>>> How would I accomplish step 1?
>> eaccelerator.check_mtime = 0
> Would that force caching of scripts that hadn't been requested by the
> webserver aswell?

No, it just does what it says. Disables mtime check to see do
eaccelerator need to reload the file.

Of course if you worry is everything cached you can make
myloadeverything.php and request that after server restarts :D

> Aslong as the scripts are in the cache they shouldn't be accessed,
> right? I just need to be 100% sure.

Not by eaccelerator, but of course you can do some stupid things
like eval(file_get_contents('my.php')).

> What I would like is to disable eaccelerator (so that apache reads the
> real php-files), wait for any requests involving eaccelerator to
> complete, then clear the cache and re-enable it.
>
> Is this not possible with eaccelerator? Does anyone with insight into
> the inner workings of eaccelerator know if it would be hard to add to
> my own version?

Look at eapanel.php.

Anders Åstrand

unread,
Sep 16, 2010, 10:25:18 AM9/16/10
to eaccel...@googlegroups.com
On Thu, 2010-09-16 at 16:53 +0300, Jani Ollikainen wrote:

The documentation says eaccelerator_clear() will clear any scripts not
currently in use by a request. Could something like the following be
used to do a graceful flush of the cache:

eaccelerator_caching(false);
while (count(eaccelerator_cached_scripts()) > 0) {
eaccelerator_clear();
sleep(1);
}
eaccelerator_caching(true);

Or will eaccelerator_caching(false) screw up any requests currently in
progress?

If the above will work it seems like all I need to do is a simple hack
to add the ability to add scripts to the cache without executing them
(which is the problem with the myloadeveryting.php approach above :) ).

Does anyone see other apparent pitfalls I'm missing?

Reply all
Reply to author
Forward
0 new messages