[Dbix-class] Storing ResultSets in the schema

Hartmaier Alexander Alexander.Hartmaier at t-systems.at
Wed Jul 16 19:49:38 BST 2008


I'd like to see a feature in dbic for this too.
I have some small tables where prefetching them slows down the queries quite a lot.
I load them on cat app startup, transform them to hashrefs and cache them for an hour with the caching plugin.
Something in dbic which transparently allows calling relationships without a db roundtrip would be great!

-Alex


-----Original Message-----
From: Ash Berlin [mailto:ash_cpan at firemirror.com]
Sent: Monday, July 07, 2008 11:13 AM
To: DBIx::Class user and developer list
Subject: Re: [Dbix-class] Storing ResultSets in the schema


On 7 Jul 2008, at 09:13, Tobias Kremer wrote:

> On server startup I'd like to fetch the complete data of one table
> and store it
> somewhere to allow faster retrieval of it later on. For this, I have
> added an
> attribute to my DBIC schema class which is set during server startup
> with the
> result of my ResultSet->search operation.
>
> Basically the data stored in the schema is generated in a custom
> ResultSet class
> with this:
>
>  $data->{ $_->code } = $_ for $self->search->all;
>
> The $data hashref is then stored in $schema during the start of
> MyApp with:
>
>  $schema->foo_data( $data );  # foo_data being my custom attribute
>
> Later on, I can access the data hashref with:
>
>  $schema->get_foo_by_key( $key )
>
> and get back the ResultSet preloaded during server start
> corresponding to $key.
>
> Now, I'm wondering if storing complete ResultSets in the schema
> might be a bad
> thing? I'm especially worried about creating memory leaks and/or
> circular
> references.
>
> Thanks!
>
> --Tobias

Yes, that would create a memory leak due to circular reference. You
want Scalar::Util::weaken.

-ash


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.rawmode.org


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*




More information about the DBIx-Class mailing list