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 $self->c->cache_set( $key, $value, @{ $self->meta }, @meta );
38 my ( $self, $key, @meta ) = @_;
39 $self->c->cache_get( $key, @{ $self->meta } );
43 my ( $self, $key, @meta ) = @_;
44 $self->c->cache_remove( $key, @{ $self->meta } );
55 Catalyst::Plugin::Cache::Curried - Curried versions of C<cache_set>,
56 C<cache_get> and C<cache_remove> that look more like a backend.
60 my $curried = $c->cache( %meta );
62 $curried->get( $key, $value ); # no need to specify %meta
66 See L<Catalyst::Plugin::Cache/META DATA> for details.
74 Create a new curried cache, that captures C<%meta>.
76 =item backend %additional_meta
78 This calls C<choose_cache_backend> on the $c object with the captured meta and
81 =item set $key, $value, %additional_meta
83 =item get $key, %additional_meta
85 =item remove $key, %additional_meta
87 Dellegate to the C<c> object's C<cache_set>, C<cache_get> or C<cache_remove>
88 with the arguments, then the captured meta from C<meta>, and then the
93 Returns the array ref that captured %meta from C<new>.
97 The captured $c object to delegate to.