[Catalyst] How to share a database connection across multiple Catalyst apps?

Simon Miner simon.miner at gmail.com
Tue Sep 7 17:59:16 GMT 2010


Hi,

I am running 3 separate Catalyst (version '5.80022) apps that use a common
(Oracle 11g) database.  Each app has a model class which wraps around a
common DBIC schema class, like so.

-----

package App1::Model::DB;



use strict;

use base 'Catalyst::Model::DBIC::Schema';



__PACKAGE__->config(

    schema_class =3D> Common::DB::Schema',

);

1;

-----

package App2::Model::DB;



use strict;

use base 'Catalyst::Model::DBIC::Schema';



__PACKAGE__->config(

    schema_class =3D> Common::DB::Schema',

);

1;

-----

package App3::Model::DB;



use strict;

use base 'Catalyst::Model::DBIC::Schema';



__PACKAGE__->config(

    schema_class =3D> Common::DB::Schema',

);

1;

-----

This setup passes changes to the Common::DB::Schema class on to the Catalyst
app model classes.



All three of these apps run under a single Apache 1.3.42/mod_perl 1.31
server.  It appears that each server process creates a unique database
connection variable for each of these apps. Although these database
connections get reused from request to request, I would like to make things
even more efficient by having a single database connection variable per
server process which gets shared across all 3 Catalyst apps.  How do I
update my model to accomplish this?



Thanks.

-- =

-- Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100907/c966c=
b57/attachment.htm


More information about the Catalyst mailing list