[Catalyst] Catalyst::Model::DBIC::Schema and caching row objects

Bill Moseley moseley at hank.org
Wed Feb 13 00:19:10 GMT 2013


Not sure if the is a Catalyst or DBIC question.

Catalyst::Model::DBIC::Schema returns objects blessed into classes related
to the app.  Then the problem is I cannot share (cached) objects across
applications.


I have a set of DBIC classes "MySchema".   I have an often used and
expensive query where I cache the returned rows.  So, a row object like
this:

$schema->resultset( 'Account' )->find( 123 );


ends up blessed into "MySchema::Result::Account".   When row objects are
cached the class name is stored so it can be thawed back into that class,
of course.


Now,  I have an app "MyApp" that uses Catalyst::Model::DBIC::Schema to
access "MySchema".  In this case row objects are blessed into:

MyApp::Model::MyDB::Account.


And that's the name that is serialized when freezing.   The problem is
another app "OtherApp" also uses the DBIC MySchema class and when it
fetches a cached entry it tries to bless them into
MyApp::Model::MyDB::Account which it cannot do.  (Needs to thaw into
"OtherApp::Model::MyDB::Account".)

    Error:  Can't locate MyApp/Model/MyDB/Account.pm in @INC


Any ideas what might be done here, short of not storing the DBIC row
objects?   I do want to end up with row objects after thawing, so they can
be used just as if I had done the query directly.


-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130212/c0786=
de2/attachment.htm


More information about the Catalyst mailing list