[Rt-commit] [svn] r1371 - in Cache-Simple-TimedExpiry: .
lib/Cache/Simple t
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Fri Aug 27 15:21:21 EDT 2004
Author: jesse
Date: Fri Aug 27 15:21:20 2004
New Revision: 1371
Modified:
Cache-Simple-TimedExpiry/ (props changed)
Cache-Simple-TimedExpiry/META.yml
Cache-Simple-TimedExpiry/Makefile
Cache-Simple-TimedExpiry/lib/Cache/Simple/TimedExpiry.pm
Cache-Simple-TimedExpiry/t/01basic.t
Log:
----------------------------------------------------------------------
r8447 at tinbook: jesse | 2004-08-27T19:20:10.936832Z
Correctness fixes and better tests from Ruz
----------------------------------------------------------------------
Modified: Cache-Simple-TimedExpiry/META.yml
==============================================================================
--- Cache-Simple-TimedExpiry/META.yml (original)
+++ Cache-Simple-TimedExpiry/META.yml Fri Aug 27 15:21:20 2004
@@ -1,5 +1,5 @@
name: Cache-Simple-TimedExpiry
-version: 0.20
+version: 0.21
abstract: A lightweight cache with timed expiration
author: Robert Spier <rspier at pobox.com>, Jesse Vincent <jesse at bestpractical.com>
license: perl
Modified: Cache-Simple-TimedExpiry/Makefile
==============================================================================
--- Cache-Simple-TimedExpiry/Makefile (original)
+++ Cache-Simple-TimedExpiry/Makefile Fri Aug 27 15:21:20 2004
@@ -18,7 +18,7 @@
# NO_META => q[1]
# PL_FILES => { }
# PREREQ_PM => { }
-# VERSION => q[0.20]
+# VERSION => q[0.21]
# dist => { PREOP=>q[$(PERL) -I. -MModule::Install::Admin -e "dist_preop(q($(DISTVNAME)))"] }
# --- MakeMaker post_initialize section:
@@ -58,11 +58,11 @@
DIRFILESEP = /
NAME = Cache::Simple::TimedExpiry
NAME_SYM = Cache_Simple_TimedExpiry
-VERSION = 0.20
+VERSION = 0.21
VERSION_MACRO = VERSION
-VERSION_SYM = 0_20
+VERSION_SYM = 0_21
DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
-XS_VERSION = 0.20
+XS_VERSION = 0.21
XS_VERSION_MACRO = XS_VERSION
XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
INST_ARCHLIB = blib/arch
@@ -243,7 +243,7 @@
DIST_CP = best
DIST_DEFAULT = tardist
DISTNAME = Cache-Simple-TimedExpiry
-DISTVNAME = Cache-Simple-TimedExpiry-0.20
+DISTVNAME = Cache-Simple-TimedExpiry-0.21
# --- MakeMaker macro section:
@@ -694,7 +694,7 @@
# --- MakeMaker ppd section:
# Creates a PPD (Perl Package Description) for a binary distribution.
ppd:
- $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0,20,0,0">' > $(DISTNAME).ppd
+ $(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0,21,0,0">' > $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <TITLE>$(DISTNAME)</TITLE>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <ABSTRACT>A lightweight cache with timed expiration</ABSTRACT>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <AUTHOR>Robert Spier <rspier at pobox.com>, Jesse Vincent <jesse at bestpractical.com></AUTHOR>' >> $(DISTNAME).ppd
Modified: Cache-Simple-TimedExpiry/lib/Cache/Simple/TimedExpiry.pm
==============================================================================
--- Cache-Simple-TimedExpiry/lib/Cache/Simple/TimedExpiry.pm (original)
+++ Cache-Simple-TimedExpiry/lib/Cache/Simple/TimedExpiry.pm Fri Aug 27 15:21:20 2004
@@ -4,7 +4,7 @@
use vars qw/$VERSION/;
-$VERSION = '0.20';
+$VERSION = '0.21';
# 0 - expiration delay
# 1 - hash
@@ -46,7 +46,7 @@
sub has_key ($$) { # exists
my ($self, $key) = @_;
- return 1 if $key && exists $self->[1]->{$key};
+ return 1 if defined $key && exists $self->[1]->{$key};
return 0;
}
@@ -99,7 +99,7 @@
while ( @{$self->[2]} && $self->[2]->[0]->[0] <$oldest_nonexpired_entry ) {
my $key = $self->[2]->[0]->[1];
- delete $self->[1]->{ $key } if exists $self->[1]->{$key};
+ delete $self->[1]->{ $key };
shift @{$self->[2]};
}
Modified: Cache-Simple-TimedExpiry/t/01basic.t
==============================================================================
--- Cache-Simple-TimedExpiry/t/01basic.t (original)
+++ Cache-Simple-TimedExpiry/t/01basic.t Fri Aug 27 15:21:20 2004
@@ -4,23 +4,49 @@
my $h = new Cache::Simple::TimedExpiry;
+is (ref($h), 'Cache::Simple::TimedExpiry');
+is ($h->has_key(), 0);
+is ($h->has_key(""), 0);
+is ($h->has_key(0), 0);
+
is ($h->expire_after(),2);
$h->expire_after(10);
is ($h->expire_after(),10);
-is(ref($h), 'Cache::Simple::TimedExpiry');
-
$h->set( 'Temp' => 'Temporary');
sleep(8);
-$h->set( 'Temp2' => 'Temporary');
+$h->set( 'Temp2' => 'Temporary2');
is ($h->fetch('Temp'), 'Temporary');
-is ($h->fetch('Temp2'), 'Temporary');
+is ($h->fetch('Temp2'), 'Temporary2');
+my @elements = sort $h->elements;
+is_deeply (\@elements, ['Temp', 'Temp2']);
+is ($h->has_key('Temp'), 1);
+is ($h->has_key('Temp2'), 1);
sleep(5);
-is ($h->fetch('Temp2'), 'Temporary');
+is ($h->fetch('Temp2'), 'Temporary2');
is ($h->fetch('Temp'), undef);
+ at elements = sort $h->elements;
+is_deeply (\@elements, ['Temp2']);
+is ($h->has_key('Temp2'), 1);
+is ($h->has_key('Temp'), 0);
sleep(6);
is ($h->fetch('Temp2'), undef);
-
+ at elements = sort $h->elements;
+is_deeply (\@elements, []);
+is ($h->has_key('Temp2'), 0);
+is ($h->has_key('Temp'), 0);
+# empty
+
+$h->expire_after(2);
+is ($h->has_key(), 0);
+$h->set( '' => 'WithEmptyKey');
+$h->set( 0 => 'WithZeroKey');
+is ($h->fetch(''), 'WithEmptyKey' );
+is ($h->fetch(0), 'WithZeroKey' );
+is ($h->has_key(''), 1);
+is ($h->has_key(0), 1);
+ at elements = sort $h->elements;
+is_deeply (\@elements, ['', 0]);
More information about the Rt-commit
mailing list