Apache:...:ImaDBI(3)

πŸ“¦
version 0.08 Β· 2 versions
, in fedora 43

✨ 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 on Ima::DBI inherits it. πŸŽ€
  • the 3rd usage inserts our method into Class::DBI. so all classes based on it inherit our method β€” but classes based directly on Ima::DBI do 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::Cache
  • Class::DBI
  • Ima::DBI

πŸ‘‘ AUTHOR πŸ‘‘

Torsten Foertsch, <torsten.foertsch@gmx.net>


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