From: Yuval Kogman Date: Mon, 19 Jun 2006 18:17:45 +0000 (+0000) Subject: rename 'delete' to 'remove' so that the interface matches Cache::Cache X-Git-Tag: v0.01~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Plugin-Cache.git;a=commitdiff_plain;h=aed484dac6fde4b3d17cebfaccea5c14560f8ce9 rename 'delete' to 'remove' so that the interface matches Cache::Cache --- diff --git a/lib/Catalyst/Plugin/Cache.pm b/lib/Catalyst/Plugin/Cache.pm index 6d1aa97..f8bd7a8 100644 --- a/lib/Catalyst/Plugin/Cache.pm +++ b/lib/Catalyst/Plugin/Cache.pm @@ -74,8 +74,8 @@ sub register_cache_backend { no warnings 'uninitialized'; Carp::croak("$backend does not look like a cache backend - " - . "it must be an object supporting get, set and delete") - unless eval { $backend->can("get") && $backend->can("set") && $backend->can("delete") }; + . "it must be an object supporting get, set and remove") + unless eval { $backend->can("get") && $backend->can("set") && $backend->can("remove") }; $c->_cache_backends->{$name} = $backend; } @@ -139,9 +139,9 @@ sub cache_get { $c->choose_cache_backend_wrapper( key => $key, @meta )->get( $key ); } -sub cache_delete { +sub cache_remove { my ( $c, $key, @meta ) = @_; - $c->choose_cache_backend_wrapper( key => $key, @meta )->delete( $key ); + $c->choose_cache_backend_wrapper( key => $key, @meta )->remove( $key ); } __PACKAGE__; diff --git a/lib/Catalyst/Plugin/Cache/Backend.pm b/lib/Catalyst/Plugin/Cache/Backend.pm index 0da37bb..99fed24 100644 --- a/lib/Catalyst/Plugin/Cache/Backend.pm +++ b/lib/Catalyst/Plugin/Cache/Backend.pm @@ -13,7 +13,7 @@ sub get { my ( $self, $key ) = @_; } -sub delete { +sub remove { my ( $self, $key ) = @_; } @@ -33,6 +33,8 @@ Catalyst::Plugin::Cache::Backend - Bare minimum backend interface. =head1 DESCRIPTION +This is less than L. + =cut diff --git a/lib/Catalyst/Plugin/Cache/Curried.pm b/lib/Catalyst/Plugin/Cache/Curried.pm index a32087e..85c329f 100644 --- a/lib/Catalyst/Plugin/Cache/Curried.pm +++ b/lib/Catalyst/Plugin/Cache/Curried.pm @@ -39,9 +39,9 @@ sub get { $self->c->cache_get( $key, @{ $self->meta } ); } -sub delete { +sub remove { my ( $self, $key ) = @_; - $self->c->cache_delete( $key, @{ $self->meta } ); + $self->c->cache_remove( $key, @{ $self->meta } ); } __PACKAGE__; @@ -53,7 +53,7 @@ __END__ =head1 NAME Catalyst::Plugin::Cache::Curried - Curried versions of C, -C and C that look more like a backend. +C and C that look more like a backend. =head1 SYNOPSIS diff --git a/t/basic.t b/t/basic.t index ac7dab6..d25f69f 100644 --- a/t/basic.t +++ b/t/basic.t @@ -21,7 +21,7 @@ use ok "Catalyst::Plugin::Cache"; sub new { bless {}, shift } sub get { ${thaw($_[0]{$_[1]}) || return} }; sub set { $_[0]{$_[1]} = freeze(\$_[2]) }; - sub delete { delete $_[0]{$_[1]} }; + sub remove { delete $_[0]{$_[1]} }; } MockApp->setup; @@ -65,13 +65,13 @@ can_ok( $c, "choose_cache_backend" ); can_ok( $c, "cache_set" ); can_ok( $c, "cache_get" ); -can_ok( $c, "cache_delete" ); +can_ok( $c, "cache_remove" ); $c->cache_set( foo => "bar" ); is( $c->cache_get("foo"), "bar", "set" ); -$c->cache_delete( "foo" ); -is( $c->cache_get("foo"), undef, "delete" ); +$c->cache_remove( "foo" ); +is( $c->cache_get("foo"), undef, "remove" ); MockApp->register_cache_backend( elk => MemoryCache->new ); diff --git a/t/currying_conf.t b/t/currying_conf.t index 6fc8be7..9a35e24 100644 --- a/t/currying_conf.t +++ b/t/currying_conf.t @@ -19,25 +19,22 @@ use ok "Catalyst::Plugin::Cache"; foo => { bah => "foo", }, - bar => MemoryCache->new, + bar => bless( {}, "SomeClass" ), }, }, ); sub config { \%config }; - package MemoryCache; - use Storable qw/freeze thaw/; - - sub new { bless {}, shift } - sub get { ${thaw($_[0]{$_[1]}) || return} }; - sub set { $_[0]{$_[1]} = freeze(\$_[2]) }; - sub delete { delete $_[0]{$_[1]} }; + package SomeClass; + sub get {} + sub set {} + sub remove {} } MockApp->setup; my $c = bless {}, "MockApp"; -MockApp->register_cache_backend( default => MemoryCache->new ); +MockApp->register_cache_backend( default => bless({}, "SomeClass") ); can_ok( $c, "curry_cache" ); can_ok( $c, "get_preset_curried" ); diff --git a/t/key_regexes.t b/t/key_regexes.t index c1709f0..8ba8367 100644 --- a/t/key_regexes.t +++ b/t/key_regexes.t @@ -28,7 +28,7 @@ use ok "Catalyst::Plugin::Cache::Choose::KeyRegexes"; sub new { bless {}, shift } sub get { ${thaw($_[0]{$_[1]}) || return} }; sub set { $_[0]{$_[1]} = freeze(\$_[2]) }; - sub delete { delete $_[0]{$_[1]} }; + sub remove { delete $_[0]{$_[1]} }; }