[Dbix-class] Caching of related resultsets

Bernhard Graf dbic1 at augensalat.de
Fri Oct 6 18:42:13 CEST 2006


I have a user - roles setup similar to 
Catalyst::Manual::Tutorial::Authentication.

My application quite often queries roles for the authenticated user
($c->user->obj) within one HTTP query.

For this purpose I defined a method in the DBIC user class like this:

sub has_role {
    my ($self, $name) = @_;
    $self->roles->find($role);
}

To save db access I'd prefer caching $user->roles->all inside the user 
object ($c->user->obj) in the first call of has_role() and access roles 
in subsequent calls to has_role() from this cache.

Is this possible?
-- 
Bernhard Graf



More information about the Dbix-class mailing list