3 package Catalyst::Plugin::Cache::Curried;
8 use base qw/Class::Accessor::Fast/;
12 __PACKAGE__->mk_accessors(qw/c meta/);
15 my ( $class, $c, @meta ) = @_;
17 my $self = $class->SUPER::new({
22 Scalar::Util::weaken( $self->{c} );
28 my ( $self, @meta ) = @_;
29 $self->c->choose_cache_backend( @{ $self->meta }, @meta )
33 my ( $self, $key, $value, @meta ) = @_;
34 @meta = ( expires => $meta[0] ) if @meta == 1;
35 $self->c->cache_set( $key, $value, @{ $self->meta }, @meta );
39 my ( $self, $key, @meta ) = @_;
40 $self->c->cache_get( $key, @{ $self->meta } );
44 my ( $self, $key, @meta ) = @_;
45 $self->c->cache_remove( $key, @{ $self->meta } );
56 Catalyst::Plugin::Cache::Curried - Curried versions of C<cache_set>,
57 C<cache_get> and C<cache_remove> that look more like a backend.
61 my $curried = $c->cache( %meta );
63 $curried->get( $key, $value ); # no need to specify %meta
67 See L<Catalyst::Plugin::Cache/META DATA> for details.
75 Create a new curried cache, that captures C<%meta>.
77 =item backend %additional_meta
79 This calls C<choose_cache_backend> on the $c object with the captured meta and
82 =item set $key, $value, %additional_meta
84 =item get $key, %additional_meta
86 =item remove $key, %additional_meta
88 Dellegate to the C<c> object's C<cache_set>, C<cache_get> or C<cache_remove>
89 with the arguments, then the captured meta from C<meta>, and then the
94 Returns the array ref that captured %meta from C<new>.
98 The captured $c object to delegate to.