[Catalyst] Re: Caching with DBIx::Class::Cursor::Cached and Catalyst::TraitFor::Model::DBIC::Schema::Caching

woosley. xu. redicaps at gmail.com
Tue Mar 22 07:20:56 GMT 2011


Hi all,
     Finally I figured out why caching did not expire for my configuration.
That's because Catalyst::Plugin::Cache::Backend::FastMmap dose not support
'set expire' at all.
     Cache::FastMmap supports setting expire time for a single key
        $fstmmap->set($key, $value, $expire_time) or
        $fstmmap->set($key, $value, {expire_time =3D> $time})

This module just skips all the other parameters except $key and $value,
which makes setting expire_time impossible when use together
Catalyst::Plugin::Cache.

##Catalyst/Plugin/Cache/Backend/FastMmap.pm

sub set {
    my ( $self, $key, $value ) =3D @_;
    $self->SUPER::set( $key =3D> \$value );
}

This can be fixed by adding the fourth parameter from C::P::Cache
sub set {
     my ( $self, $key, $value ) =3D @_;
    $self->SUPER::set( $key =3D> \$value, $_[3] ? $_[3] : () );
}

So I think settting cache_for  by using
Catalyst::TraitFor::Model::DBIC::Schema::Caching would not work if you are
using FastMmap as backend. It expires the cache only because Cache::FastMmap
has a default expire strategy.

I summited a bug to C::P::C::B::FastMmap and hope this would be fixed soon.




2011/3/15 woosley. xu. <redicaps at gmail.com>

> Hi everyone,
>     I  configured my application  to use DBIx::Class::Cursor::Cached
> following the guide provied by
> Catalyst::TraitFor::Model::DBIC::Schema::Caching
>
> Here is my configuration sample
>
> __PACKAGE__->config->{'Plugin::Cache'}{backend} =3D {
>     store =3D> "FastMmap",
>     share_file =3D> '/tmp/fastmmap',
>     cache_size =3D> '50m',
>     unlink_on_exit =3D> 1,
> };
>
> <Model::DB>
>    schema_class SEA::DB
>    traits Caching
>    <connect_info>
>         dsn
>         user
>         password
>    </connect_info>
> </Model::DB>
>
>
> And I set cache time to 60 seconds to view the effect. In
> ResultSet/Charge.pm, I have some seach like
>
>  my @result =3D $self->search(
>         $search,
>         {   select =3D> ['nn', 'ac', {count =3D> 'nsea'}, {sum =3D> 'nsea=
'}],
>             as       =3D> [qw/nn ac sea_count total/],
>             group_by =3D> [qw/nn/],
>             cache_for =3D> 60,
>         }
>     )->all;
>
>
> Caching seems to be working, but after waiting for more than 60 hours, the
> cache result is still there. I am expecting this cache would be refreshed.
> Am I missing something?
>
> Thanks.
>
> --
> Woosley.Xu
>
>
>
>


-- =

Woosley.Xu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110322/e2f45=
10a/attachment.htm


More information about the Catalyst mailing list