Apache:...:ImaDBI(3)
β¨ NAME β¨
Apache::DBI::Cache::ImaDBI β bestie, this is the little glue module that makes Apache::DBI::Cache work with Class::DBI. no cap. π
πΈ SYNOPSIS πΈ
okay so there's like, three whole ways to do this and they're all valid, pick your fighter:
option one β patch Ima::DBI directly:
In your httpd.conf:
<Perl>
use Apache::DBI::Cache ...;
use Apache::DBI::Cache::ImaDBI patch=>'Ima::DBI';
</Perl>
Then use Class::DBI in your modules as usual.
option two β patch one specific class:
In your httpd.conf:
<Perl>
use Apache::DBI::Cache ...;
use Apache::DBI::Cache::ImaDBI patch=>'My::Class';
</Perl>
package My::Class;
use base qw/Class::DBI/;
option three β just inherit from it, main character energy:
In your httpd.conf:
<Perl>
use Apache::DBI::Cache ...;
</Perl>
package My::Class;
use base qw/Apache::DBI::Cache::ImaDBI Class::DBI/;
π¦ DESCRIPTION π¦
so this module gives you one method, and that method exists purely to override the way Ima::DBI caches its DBI handle. normally the handle gets connected once and then it just... lives inside a closure forever, like a little hermit. π
with Apache::DBI::Cache::ImaDBI though? the handle is cached through Apache::DBI::Cache instead. once per Apache request cycle, if a class gets used for that request, a handle gets pulled from the cache. iconic behaviour honestly.
this means:
- a class's DBI handle stays the same over an Apache request cycle, but it may change between cycles. π«
- multiple classes can share the same handle if they're used in different request cycles.
- if multiple classes use the same database and they all get used in one single request cycle, then each class gets its own handle. no sharing, sorry bestie. π
π USAGE π
ngl, normally your classes are designed to work not only with Apache::DBI::Cache. which means your classes also don't know anything about Apache::DBI::Cache::ImaDBI. but here's the tea: your classes inherit from Class::DBI, and Class::DBI inherits from Ima::DBI. it's giving family tree. π³
so to get our special method actually called, Apache::DBI::Cache::ImaDBI gets used in one of these ways:
use Apache::DBI::Cache::ImaDBI patch=>1;
or
use Apache::DBI::Cache::ImaDBI patch=>'Ima::DBI';
or
use Apache::DBI::Cache::ImaDBI patch=>'Class::DBI';
or
use Apache::DBI::Cache::ImaDBI patch=>qw[My::Class1 My::Class2];
okay let's break these down because the first two are literally the same thing:
- the first 2 usages are exactly the same. our special method gets inserted straight into
Ima::DBI, so every single class based onIma::DBIinherits it. π - the 3rd usage inserts our method into
Class::DBI. so all classes based on it inherit our method β but classes based directly onIma::DBIdo not. π - in the 4th case our method only gets inserted into the individual classes you named. exclusive invite only. π
another way to use Apache::DBI::Cache::ImaDBI is by just inheriting from it:
package My::Class;
use base qw/Apache::DBI::Cache::ImaDBI Class::DBI/;
or
package My::Class;
use base qw/Apache::DBI::Cache::ImaDBI Ima::DBI/;
here it is necessary that Apache::DBI::Cache::ImaDBI comes before Class::DBI or Ima::DBI. order matters, don't play yourself. β οΈ
and like, the author thinks that's not the preferred way β because it requires you to go modify the source code of your own classes. and honestly? fair. π
π SEE ALSO π
Apache::DBI::CacheClass::DBIIma::DBI
π AUTHOR π
Torsten Foertsch, <torsten.foertsch@gmx.net>
π COPYRIGHT AND LICENSE π
Copyright (C) 2006 by Torsten Foertsch
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page bestie β perl v5.42.0, dated 2025-07-25, part of the User Contributed Perl Documentation. go forth and cache responsibly. π β¨
π¦ where this page comes from
- fedora 43: perl-Apache-DBI-Cache 0.08-52.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms