Suppose we have two tables: events and people, where each event has a person
associated with it, e.g. in MySchema::Result::Event,
__PACKAGE__->belongs_to(
"person",
"MySchema::Result::Person",
{ id => "person_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
The naive way of handling events is to do something like
foreach my $event (@events) {
my $person = $event->person;
...
}
but that is inefficient when there are many events associated with a small
number of people.
What is the best way to modify customize the person method to memoize
people, so that I can code the naive way (which is easier to read) but have
DBIC do the right thing?
_______________________________________________
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]