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

_______________________________________________
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/[EMAIL PROTECTED]

Reply via email to