[CDBI] Use with mod_perl caching question

Edward J. Sabol sabol at alderaan.gsfc.nasa.gov
Thu Dec 13 17:20:25 GMT 2007


> but neither of these consistently return correct data from the db.
> Looks to me like they just return from their local caches.
>
> My question is, how do I force cdbi to always go to the db for
> specific requests?
>
> I can see that if there were only one process updating the database,
> that the cached version of my modules would always have the correct
> data, but I run in a mod_perl environment with multiple child
> processes, and also have external processes that update the db --
> setting status, as a prime example.

CDBI doesn't have a "cache". It has an object index, which you can disable
rather easily (RTFM). If you do disable it and the problem goes away, then
the real source of your problem is scoping. More info:

http://wiki.class-dbi.com/wiki/Common_problems#Old_data_due_to_object_index
http://search.cpan.org/~tmtm/Class-DBI/lib/Class/DBI.pm#UNIQUENESS_OF_OBJECTS_IN_MEMORY

There is some historical context at

http://wiki.class-dbi.com/wiki/Using_with_mod_perl

which you should familiarize yourself with. (Are you using Ima::DBI 0.35? If
not, upgrade or utilize the solutions described at this page.) Also, you
should add a rollback cleanup handler if you modify the database from
mod_perl.

Hope this helps,
Ed



More information about the ClassDBI mailing list