[Dbix-class] cache=> 1 and has_many?

George Hartzell hartzell at alerce.com
Fri Aug 11 04:00:56 CEST 2006


[by now you're probalby sick of the cartoon version of my schema, but
 here it is...]

I'm using DBIx-Class-0.06003, and have cache => 1 in my ->search.

I have an 

  rn
    has_many nodes

  nodes
    has_many attrs

and I have a bunch of code that looks vaguely like this:

  ($n1, $n2) = $rn->nodes;

  ($apes_1) = grep {$_->name eq 'APE'} $n1->attrs();
  ($meece_1) = grep {$_->name eq 'MOOSE'} $n1->attrs();
  ($mice_1) = grep {$_->name eq 'MOUSE'} $n1->attrs();

  ($apes_2) = grep {$_->name eq 'APE'} $n2->attrs();
  ($meece_2) = grep {$_->name eq 'MOOSE'} $n2->attrs();
  ($mice_2) = grep {$_->name eq 'MOUSE'} $n2->attrs();

And, watching the output generated by setting
DBIX_CLASS_STORAGE_DBI_DEBUG I see it constantly going back to the
database for the same set of attrs.

Shouldn't the cacheing be avoiding this?

Is the cachedness somehow associated with $rn, but not the nodes that
I get from ->nodes()?

Thanks,

g.



More information about the Dbix-class mailing list