[Melbourne-pm] Apache::DBI

Stephen Edmonds Stephen.Edmonds at its.monash.edu.au
Thu Feb 15 15:38:03 PST 2007


It isn't that Apache::DBI overrides DBI->connect().  What happens is 
that DBI itself is written to detect if Apache::DBI is loaded and if so 
use that connect method.

If you bring up the DBI code [1] and search for Apache you will find 
logic that changes the connect methods.

I suppose you could do it without changing the original module but the 
only way I can think of at the moment would be symbol table manipulation 
which may not work depending on when the modules are loaded.

Another option would be a wrapper or sub-class that added in the caching.



[1] http://search.cpan.org/src/TIMB/DBI-1.53/DBI.pm

Scott Penrose wrote:
> Hey Guys
> I am working on a set of caching modules for mod_perl.
> I absolutely love the transparency of Apache::DBI - you simply load  
> the module and then any time you use DBI->connect - it uses the  
> cached - or precached versions.
> However looking at the code:
> 	http://search.cpan.org/src/PGOLLUCCI/Apache-DBI-1.05/lib/Apache/DBI.pm
> I can't figure out how this works.
> The code for precache makes sense. But I can't figure out where in  
> the code it takes over from DBI->connect. I do know it must be loaded  
> before any other module does a "use DBI".
> Any ideas guys? My code will be a pre-cached version of a some XSL  
> modules - which means that you do nothing new and your code will use  
> the precompiled XSL - where as traditionally everyone implements  
> their own cache - this means your code works faster when moving from  
> CGI to mod_perl - with no code change, or even from Catalyst stand  
> alone into Catalyst via mod_perl.
> Scott

Stephen Edmonds
Senior Portal Developer / Integrator
Flexible Learning and Teaching Program
ITS, Monash University

More information about the Melbourne-pm mailing list