NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP caching options

Gary Mort garyamort at gmail.com
Mon Mar 21 17:01:13 EDT 2011


Before I go an re-invent the wheel, I figured I'd ask here first.

Does anyone know of a PHP cache system[like APC and XCache] which has 
the following features:

1) Saves the cached files to a tmpfs drive instead of using their own 
shared memory pool?
2) Saves evals as well as files?
3) Keeps track of cached files[via inotify or some other means] and when 
new copies are saved, updates the cache
4) For files that exist in the cache to begin with, when updating the 
cache if the PHP file fails to compile[syntax errors, etc], keep using 
the cached file and wait until a 'good' copy of the file is saved
5) Logging options so that alerts can be generated when a file has an error.


Basically, it strikes me that most of the popular systems are somewhat 
based on being 'universal' and do not take advantage of current Linux 
features which can save time.  For example, by using a tmpfs drive all 
the cached data can be "shared" between multiple systems by doing a 
simple rsync between the systems.  In fact, you can even rsync it over 
to disk storage on one system for 'permanent' storage and then if you 
reboot your PHP server, you can preload your cache by pulling data from 
the central server.  All using basic file system access.

With inotify, the cache server can keep an eye on the source of the 
files and automatically update the cache.

If your planning your cache to contain most of your active PHP code to 
begin with, there really is no reason to cache buggy code.  If there is 
a good copy in the cache, reject updates until they at least compile.

And of course, the cache server might as well log problems so you can 
get them via email, instant message, sms, etc right away.

A sidebit is caching evals, since it does not seem that many systems do 
this....which is understandable as it is beneficial to avoid evals to 
begin with.  However, CMS systems often use Evals to allow configuration 
of code without needing to have files on the server.   With all that 
code stored in the database, it just makes sense to pre-compile and 
cache it.

Since APC and XCache are open source, it is easy enough to pull the 
logic for compiling/caching files when included from them...so really 
it's just the other stuff that needs to be built.





More information about the talk mailing list