[#10396] Add caching to autoloader
Summary Add caching to autoloader
Queue Horde Framework Packages
Queue Version Git master
Type Bug
State Resolved
Priority 1. Low
Owners jan@horde.org
Requester jan@horde.org
Created 2011-07-29 (3738 days ago)
Due
Updated 2011-11-14 (3630 days ago)
Assigned
Resolved 2011-11-14 (3630 days ago)
Milestone
Patch No

Comments
Jan Schneider <jan@horde.org> 2011-07-29 16:53:07
For most page requests, loading all the PHP files through the 
autoloader is the most expensive operation now. The actual file 
loading can be improved by using a bytecode cache. Even more expensive 
is the class name to file path mapping though, especially the regular 
expressions.
The idea is to store this map directly, i.e. without using Horde_Cache 
for obvious reasons, in a cache. Since users interested in speeding up 
the file loading are using APC or similar anyway, the autoloader 
should use such a bytecode cache for caching the map too, if the 
extension supports arbitrary caching.

Jan Schneider <jan@horde.org> 2011-07-29 21:52:58
POC, works pretty well, still needs a way to invalidate the cache.

Michael Slusarz <slusarz@horde.org> 2011-08-01 20:10:47
> POC, works pretty well, still needs a way to invalidate the cache.

What about providing a *very* basic temp file fallback if none of 
these caching backends are available?  (e.g. using sys_get_temp_dir(), 
file_get_contents(), and file_put_contents()).

Jan Schneider <jan@horde.org> 2011-09-06 16:52:43
>> POC, works pretty well, still needs a way to invalidate the cache.
>
> What about providing a *very* basic temp file fallback if none of 
> these caching backends are available?  (e.g. using 
> sys_get_temp_dir(), file_get_contents(), and file_put_contents()).

http://git.horde.org/horde-git/-/commit/192c56b7c64ad886b25ae4fb250eb853e310ff01

Jan Schneider <jan@horde.org> 2011-09-16 15:46:13
One solution could be to make this a separate non-dependant package, 
and make the package class decorating the original default autoloader. 
Admins would have to explicitly install this package to enable 
autoloader caching, thus we won't need any configuration to disable 
it, and we can make it the admin's job to take care of cache cleaning 
if necessary. A small script could help with that.
In Horde, we would check if this package's class file exist, and load 
that, otherwise fall back to the default autoloader.
Does anybody see any issues with this approach?

Git Commit <commits@lists.horde.org> 2011-11-14 05:03:14
Changes have been made in Git for this ticket:

Add Autoloader_Cache library to cache class maps from the Autoloader 
package (Request #10396).

  3 files changed, 609 insertions(+), 0 deletions(-)
http://git.horde.org/horde-git/-/commit/351190d0cd4e7ae85690fab2b861b6263cda23d6