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} )
29 my ( $self, @meta ) = @_;
30 $self->c->choose_cache_backend( @{ $self->meta }, @meta )
34 my ( $self, $key, $value, @meta ) = @_;
35 @meta = ( expires => $meta[0] ) if @meta == 1;
36 $self->c->cache_set( $key, $value, @{ $self->meta }, @meta );
40 my ( $self, $key ) = @_;
41 $self->c->cache_get( $key, @{ $self->meta } );
45 my ( $self, $key ) = @_;
46 $self->c->cache_remove( $key, @{ $self->meta } );
50 my ($self, $key, $code, @meta) = @_;
51 @meta = ( expires => $meta[0] ) if @meta == 1;
52 $self->c->cache_compute( $key, $code, @{ $self->meta }, @meta );
63 Catalyst::Plugin::Cache::Curried - Curried versions of C<cache_set>,
64 C<cache_get> and C<cache_remove> that look more like a backend.
68 my $curried = $c->cache( %meta );
70 $curried->get( $key, $value ); # no need to specify %meta
74 See L<Catalyst::Plugin::Cache/META DATA> for details.
82 Create a new curried cache, that captures C<%meta>.
84 =item backend %additional_meta
86 This calls C<choose_cache_backend> on the $c object with the captured meta and
89 =item set $key, $value, %additional_meta
91 =item get $key, %additional_meta
93 =item remove $key, %additional_meta
95 =item compute $key, $code, %additional_meta
97 Dellegate to the C<c> object's C<cache_set>, C<cache_get>, C<cache_remove>
98 or C<cache_compute> with the arguments, then the captured meta from C<meta>,
99 and then the additional meta.
103 Returns the array ref that captured %meta from C<new>.
107 The captured $c object to delegate to.