DBIx::MoCoのhas_manyリレーション
結果オブジェクトがexpireなしでキャッシュされるのか…。ちょっとハマった。
回避策としては、リレーションテーブルにアクセスする際はflush_has_many_keysメソッドでキャッシュを消すことだけど、リレーション設定の時、
cache => 'nocache' # or number for expire time
っていうパラメータに対応できるといいと思う。こういう感じ
--- Relation.pm 2009-03-17 13:38:46.000000000 +0900 +++ Relation.pm.new 2009-03-17 13:44:17.000000000 +0900 @@ -133,7 +133,13 @@ max_offset => $max_off || -1, }; - $self->cache($cache_key, $keys); + my $exp_time = $option->{cache}; + if (!$exp_time) { + $self->cache($cache_key, $keys); + } + elsif ($exp_time ne 'nocache' && $exp_time =~ /\A\d+\z/) { + $self->cache($cache_key, $keys, $exp_time); + } # warn @{$self->{$array_key}}; }