[Catalyst] Multiple DB, single instance of Cat

Andrew Rodland arodland at comcast.net
Fri Sep 12 00:25:03 BST 2008


On Thursday 11 September 2008 05:58:31 pm Nigel Stuckey wrote:
> Matt
>
> I stand corrected on DBIx! Yes, indeed I mean DBIx::Class.
>
> The code is in and works, but has a couple of issues. Firstly, it
> creates new classes and carries out a DB connect every time there is
> a request. Is there a way to make it more efficient by caching the
> classes and DB connects once there is a successful authentication?
>
If you know what all of the possible "organizations" are, then write a model 
that instantiates all the DB connections (schemas, whatever) at 'new' time, 
then returns the appropriate one at ACCEPT_CONTEXT time. It's the "here's one 
we prepared earlier" approach. If that's not feasible, it should be obvious 
how to change it to doing nothing at startup, creating connections on demand, 
and "caching" them for the life of the process.

Andrew




More information about the Catalyst mailing list