diff -Nru libmemoize-expirelru-perl-0.55/Changes libmemoize-expirelru-perl-0.56/Changes --- libmemoize-expirelru-perl-0.55/Changes 2000-04-12 02:02:23.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/Changes 2016-07-06 23:04:27.000000000 +0000 @@ -1,13 +1,29 @@ -Revision history for Perl extension String::Strip +Revision history for Perl module Memoize::ExpireLRU -0.52 Wed Mar 8 23:08:34 EST 2000 - - original version +0.56 2016-07-07 NEILB + - Switched from using the deprecated TIE interface for Memoize + - Refactored to current traditional directory structure + - Switched to Dist::Zilla -0.53 Thu Apr 6 23:34:12 EDT 2000 - - Tiny bug fixes (!= -> ne) +0.55_02 2016-07-02 NEILB + - Switched from using the deprecated TIE interface for Memoize, + RT#115091 -0.54 Tue Apr 11 21:46:37 EDT 2000 - - Big bug fixes. Consider this the first working version +0.55_01 2016-03-09 NEILB + - Switched to Dist::Zilla + - Moved ExpireLRU.pm to lib/Memoize/ExpireLRU.pm + - Moved test.pl to t/02-original.t + - Updated this file to follow CPAN::Changes::Spec, and most recent + release first. + - Added github repo to doc -0.55 Tue Apr 11 21:46:37 EDT 2000 +0.55 2000-04-12 BPOWERS - Just why can't you save from a screwed up upload on PAUSE? + - Big bug fixes. Consider this the first working version + +0.53 2000-04-07 BPOWERS + - Tiny bug fixes (!= -> ne) + +0.52 2000-03-14 BPOWERS + - original version + diff -Nru libmemoize-expirelru-perl-0.55/debian/changelog libmemoize-expirelru-perl-0.56/debian/changelog --- libmemoize-expirelru-perl-0.55/debian/changelog 2010-04-12 13:01:52.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/debian/changelog 2016-10-11 20:39:07.000000000 +0000 @@ -1,3 +1,38 @@ +libmemoize-expirelru-perl (0.56-1) unstable; urgency=medium + + * Team upload + + [ Ansgar Burchardt ] + * debian/control: Convert Vcs-* fields to Git. + + [ Salvatore Bonaccorso ] + * debian/copyright: Replace DEP5 Format-Specification URL from + svn.debian.org to anonscm.debian.org URL. + * Change Vcs-Git to canonical URI (git://anonscm.debian.org) + * Change search.cpan.org based URIs to metacpan.org based URIs + + [ Axel Beckert ] + * Fix missing license short name in debian/copyright + + [ gregor herrmann ] + * Strip trailing slash from metacpan URLs. + + [ Salvatore Bonaccorso ] + * Update Vcs-Browser URL to cgit web frontend + * debian/control: Use HTTPS transport protocol for Vcs-Git URI + + [ Florian Schlichting ] + * New upstream version 0.56 (closes: #826442) + * Update stand-alone license paragraphs to commonly used version (not + limiting Debian to GNU/Linux, directly linking to GPL-1) + * Bump dh compat to level 9 + * Stop shipping README (irrelevant for Debian) + * Update to copyright-format 1.0 + * Declare compliance with Debian Policy 3.9.8 + * Mark package autopkgtest-able + + -- Florian Schlichting Tue, 11 Oct 2016 22:39:07 +0200 + libmemoize-expirelru-perl (0.55-1) unstable; urgency=low * Initial Release (closes: #577512). diff -Nru libmemoize-expirelru-perl-0.55/debian/compat libmemoize-expirelru-perl-0.56/debian/compat --- libmemoize-expirelru-perl-0.55/debian/compat 2010-04-12 11:56:32.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/debian/compat 2016-10-11 20:39:07.000000000 +0000 @@ -1 +1 @@ -7 +9 diff -Nru libmemoize-expirelru-perl-0.55/debian/control libmemoize-expirelru-perl-0.56/debian/control --- libmemoize-expirelru-perl-0.55/debian/control 2010-04-12 13:05:25.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/debian/control 2016-10-11 20:39:07.000000000 +0000 @@ -1,15 +1,15 @@ Source: libmemoize-expirelru-perl Section: perl Priority: optional -Build-Depends: debhelper (>= 7) +Build-Depends: debhelper (>= 9) Build-Depends-Indep: perl Maintainer: Debian Perl Group Uploaders: Krzysztof Krzyżaniak (eloy) -Standards-Version: 3.8.4 -Homepage: http://search.cpan.org/dist/Memoize-ExpireLRU/ -Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libmemoize-expirelru-perl/ -Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libmemoize-expirelru-perl/ - +Standards-Version: 3.9.8 +Homepage: https://metacpan.org/release/Memoize-ExpireLRU +Vcs-Git: https://anonscm.debian.org/git/pkg-perl/packages/libmemoize-expirelru-perl.git +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libmemoize-expirelru-perl.git +Testsuite: autopkgtest-pkg-perl Package: libmemoize-expirelru-perl Architecture: all diff -Nru libmemoize-expirelru-perl-0.55/debian/copyright libmemoize-expirelru-perl-0.56/debian/copyright --- libmemoize-expirelru-perl-0.55/debian/copyright 2010-04-12 13:08:47.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/debian/copyright 2016-10-11 20:39:07.000000000 +0000 @@ -1,15 +1,11 @@ -Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 -Maintainer: Brent B. Powers (B2Pi), Powers@B2Pi.com -Source: http://search.cpan.org/dist/Memoize-ExpireLRU/ -Name: Memoize-ExpireLRU +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Memoize-ExpireLRU +Upstream-Contact: Brent B. Powers (B2Pi), Powers@B2Pi.com +Source: https://metacpan.org/release/Memoize-ExpireLRU Files: * Copyright: 1999, 2000, Brent B. Powers (B2Pi), Powers@B2Pi.com - . - Copyright(c) 1999 Brent B. Powers. All rights reserved. This program - is free software, you may redistribute it and/or modify it under the - same terms as Perl itself. -License: +License: Artistic or GPL-1+ Files: debian/* Copyright: 2010, Krzysztof Krzyżaniak (eloy) @@ -19,8 +15,8 @@ This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, which comes with Perl. . - On Debian GNU/Linux systems, the complete text of the Artistic License - can be found in `/usr/share/common-licenses/Artistic' + On Debian systems, the complete text of the Artistic License can be + found in `/usr/share/common-licenses/Artistic'. License: GPL-1+ This program is free software; you can redistribute it and/or modify @@ -28,5 +24,5 @@ the Free Software Foundation; either version 1, or (at your option) any later version. . - On Debian GNU/Linux systems, the complete text of the GNU General - Public License can be found in `/usr/share/common-licenses/GPL' + On Debian systems, the complete text of version 1 of the GNU General + Public License can be found in `/usr/share/common-licenses/GPL-1'. diff -Nru libmemoize-expirelru-perl-0.55/debian/libmemoize-expirelru-perl.docs libmemoize-expirelru-perl-0.56/debian/libmemoize-expirelru-perl.docs --- libmemoize-expirelru-perl-0.55/debian/libmemoize-expirelru-perl.docs 2010-04-12 11:56:32.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/debian/libmemoize-expirelru-perl.docs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -README diff -Nru libmemoize-expirelru-perl-0.55/debian/upstream/metadata libmemoize-expirelru-perl-0.56/debian/upstream/metadata --- libmemoize-expirelru-perl-0.55/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/debian/upstream/metadata 2016-10-11 20:30:05.000000000 +0000 @@ -0,0 +1,6 @@ +--- +Archive: CPAN +Contact: Brent B. Powers +Name: Memoize-ExpireLRU +Repository: https://github.com/neilb/Memoize-ExpireLRU.git +Repository-Browse: https://github.com/neilb/Memoize-ExpireLRU diff -Nru libmemoize-expirelru-perl-0.55/debian/watch libmemoize-expirelru-perl-0.56/debian/watch --- libmemoize-expirelru-perl-0.55/debian/watch 2010-04-12 11:56:32.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/debian/watch 2014-03-04 10:45:55.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://search.cpan.org/dist/Memoize-ExpireLRU/ .*/Memoize-ExpireLRU-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ +https://metacpan.org/release/Memoize-ExpireLRU .*/Memoize-ExpireLRU-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ diff -Nru libmemoize-expirelru-perl-0.55/dist.ini libmemoize-expirelru-perl-0.56/dist.ini --- libmemoize-expirelru-perl-0.55/dist.ini 1970-01-01 00:00:00.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/dist.ini 2016-07-06 23:04:27.000000000 +0000 @@ -0,0 +1,19 @@ +name = Memoize-ExpireLRU +author = Brent B. Powers +license = Perl_5 +copyright_holder = Brent B. Powers +copyright_year = 1999 + +version = 0.56 + +[@Filter] +-bundle = @Basic +-remove = Readme +[PkgVersion] +[AutoPrereqs] +[MetaJSON] +[GithubMeta] + +[Git::Tag] +tag_message= +[Git::Push] diff -Nru libmemoize-expirelru-perl-0.55/ExpireLRU.pm libmemoize-expirelru-perl-0.56/ExpireLRU.pm --- libmemoize-expirelru-perl-0.55/ExpireLRU.pm 2000-04-12 02:02:11.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/ExpireLRU.pm 1970-01-01 00:00:00.000000000 +0000 @@ -1,395 +0,0 @@ -########################################################################### -# File - ExpireLRU.pm -# Created 12 Feb, 2000, Brent B. Powers -# -# Purpose - This package implements LRU expiration. It does this by -# using a bunch of different data structures. Tuning -# support is included, but costs performance. -# -# ToDo - Test the further tie stuff -# -# Copyright(c) 2000 Brent B. Powers and B2Pi LLC -# -# You may copy and distribute this program under the same terms as -# Perl itself. -# -########################################################################### -package Memoize::ExpireLRU; - -use strict; -use AutoLoader qw(AUTOLOAD); -use Carp; -use vars qw($DEBUG $VERSION); - -$DEBUG = 0; -$VERSION = '0.55'; - -# Usage: memoize func , -# TIE => [ -# Memoize::ExpireLRU, -# CACHESIZE => n, -# TUNECACHESIZE => m, -# INSTANCE => IDString -# TIE => [...] -# ] - -############################################# -## -## This used to all be a bit more reasonable, but then it turns out -## that Memoize doesn't call FETCH if EXISTS returns true and it's in -## scalar context. Thus, everything really has to be done in the -## EXISTS code. Harumph. -## -############################################# - -use vars qw(@AllTies $EndDebug); - -$EndDebug = 0; - -1; - -sub TIEHASH { - my ($package, %args, %cache, @index, @Tune, @Stats); - ($package, %args)= @_; - my($self) = bless \%args => $package; - $self->{CACHESIZE} or - croak "Memoize::ExpireLRU: CACHESIZE must be specified >0; aborting"; - $self->{TUNECACHESIZE} ||= 0; - delete($self->{TUNECACHESIZE}) unless $self->{TUNECACHESIZE}; - $self->{C} = \%cache; - $self->{I} = \@index; - defined($self->{INSTANCE}) or $self->{INSTANCE} = "$self"; - foreach (@AllTies) { - if ($_->{INSTANCE} eq $self->{INSTANCE}) { - croak "Memoize::ExpireLRU: Attempt to register the same routine twice; aborting"; - } - } - if ($self->{TUNECACHESIZE}) { - $EndDebug = 1; - for (my $i = 0; $i < $args{TUNECACHESIZE}; $i++) { - $Stats[$i] = 0; - } - $self->{T} = \@Stats; - $self->{TI} = \@Tune; - $self->{cm} = $args{ch} = $args{th} = 0; - - } - - if ($self->{TIE}) { - my($module, $modulefile, @opts, $rc, %tcache); - ($module, @opts) = @{$args{TIE}}; - $modulefile = $module . '.pm'; - $modulefile =~ s{::}{/}g; - eval { require $modulefile }; - if ($@) { - croak "Memoize::ExpireLRU: Couldn't load hash tie module `$module': $@; aborting"; - } - $rc = (tie %tcache => $module, @opts); - unless ($rc) { - croak "Memoize::ExpireLRU: Couldn't tie hash to `$module': $@; aborting"; - } - - ## Preload our cache - foreach (keys %tcache) { - $self->{C}->{$_} = $tcache{$_} - } - $self->{TiC} = \%tcache; - } - - push(@AllTies, $self); - return $self; -} - -sub EXISTS { - my($self, $key) = @_; - - $DEBUG and print STDERR " >> $self->{INSTANCE} >> EXISTS: $key\n"; - - if (exists $self->{C}->{$key}) { - my($t, $i);#, %t, %r); - - ## Adjust the positions in the index cache - ## 1. Find the old entry in the array (and do the stat's) - $i = _find($self->{I}, $self->{C}->{$key}->{t}, $key); - if (!defined($i)) { - print STDERR "Cache trashed (unable to find $key)\n"; - DumpCache($self->{INSTANCE}); - ShowStats; - die "Aborting..."; - } - - ## 2. Remove the old entry from the array - $t = splice(@{$self->{I}}, $i, 1); - - ## 3. Update the timestamp of the new array entry, as - ## well as that in the cache - $self->{C}->{$key}->{t} = $t->{t} = time; - - ## 4. Store the updated entry back into the array as the MRU - unshift(@{$self->{I}}, $t); - - ## 5. Adjust stats - if (defined($self->{T})) { - $self->{T}->[$i]++ if defined($self->{T}); - $self->{ch}++; - } - - if ($DEBUG) { - print STDERR " Cache hit at $i"; - print STDERR " ($self->{ch})" if defined($self->{T}); - print STDERR ".\n"; - } - - return 1; - } else { - if (exists($self->{TUNECACHESIZE})) { - $self->{cm}++; - $DEBUG and print STDERR " Cache miss ($self->{cm}).\n"; - ## Ughhh. A linear search - my($i, $j); - for ($i = $j = $self->{CACHESIZE}; $i <= $#{$self->{T}}; $i++) { - next unless defined($self->{TI}) - && defined($self->{TI}->[$i- $j]) - && defined($self->{TI}->[$i - $j]->{k}) - && $self->{TI}->[$i - $j]->{k} eq $key; - $self->{T}->[$i]++; - $self->{th}++; - $DEBUG and print STDERR " TestCache hit at $i. ($self->{th})\n"; - splice(@{$self->{TI}}, $i - $j, 1); - return 0; - } - } else { - $DEBUG and print STDERR " Cache miss.\n"; - } - return 0; - } -} - -sub STORE { - my ($self, $key, $value) = @_; - $DEBUG and print STDERR " >> $self->{INSTANCE} >> STORE: $key $value\n"; - - my(%r, %t); - $t{t} = $r{t} = time; - $r{v} = $value; - $t{k} = $key; - - # Store the value into the hash - $self->{C}->{$key} = \%r; - ## As well as the tied cache, if it exists - $self->{TC}->{$key} = $value if defined($self->{TC}); - - # By definition, this item is the MRU, so add it to the beginning - # of the LRU queue. Since this is a STORE, we know it doesn't already - # exist. - unshift(@{$self->{I}}, \%t); - ## Update the tied cache - $self->{TC}->{$key} = $value if defined($self->{TC}); - - ## Do we have too many entries? - while (scalar(@{$self->{I}}) > $self->{CACHESIZE}) { - ## Chop off whatever is at the end - ## Get the key - $key = pop(@{$self->{I}}); - delete($self->{C}->{$key->{k}}); - delete($self->{TC}->{$key->{k}}) if defined($self->{TC}); - ## Throw it to the beginning of the test cache - unshift(@{$self->{TI}}, $key) if defined($self->{T}); - } - - ## Now, what about the Tuning Index - if (defined($self->{T})) { - if (scalar(@{$self->{TI}}) > $self->{TUNECACHESIZE} - $self->{CACHESIZE}) { - $#{$self->{TI}} = $self->{TUNECACHESIZE} - $self->{CACHESIZE} - 1; - } - } - - $value; -} - -sub FETCH { - my($self, $key) = @_; - - $DEBUG and print STDERR " >> $self->{INSTANCE} >> FETCH: $key\n"; - - return $self->{C}->{$key}->{v}; -} - -sub _find ( $$$ ) { - my($Aref, $time, $key) = @_; - my($t, $b, $n, $l); - - $t = $#{$Aref}; - $n = $b = 0; - $l = -2; - - while ($time != $Aref->[$n]->{t}) { - if ($time < $Aref->[$n]->{t}) { - $b = $n; - } else { - $t = $n; - } - if ($t <= $b) { - ## Trouble, we're out. - if ($Aref->[$t]->{t} == $time) { - $n = $t; - } elsif ($Aref->[$b]->{t} == $time) { - $n = $b; - } else { - ## Really big trouble - ## Complain loudly - print "Trouble\n"; - return undef; - } - } else { - $n = $b + (($t - $b) >> 1); - $n++ if $l == $n; - $l = $n; - } - } - ## Drop down in the array until the time isn't the time - while (($n > 0) && ($time == $Aref->[$n-1]->{t})) { - $n--; - } - while (($time == $Aref->[$n]->{t}) && ($key ne $Aref->[$n]->{k})) { - $n++; - } - if ($key ne $Aref->[$n]->{k}) { - ## More big trouble - print "More trouble\n"; - return undef; - } - return $n; -} - -END { - print STDERR ShowStats() if $EndDebug; -} - -__END__ - -sub DumpCache ( $ ) { - ## Utility routine to display the caches of the given instance - my($Instance, $self, $p) = shift; - foreach $self (@AllTies) { - - next unless $self->{INSTANCE} eq $Instance; - - $p = "$Instance:\n Cache Keys:\n"; - - foreach my $x (@{$self->{I}}) { - ## The cache is at $self->{C} (->{$key}) - $p .= " '$x->{k}'\n"; - } - $p .= " Test Cache Keys:\n"; - foreach my $x (@{$self->{TI}}) { - $p .= " '$x->{k}'\n"; - } - return $p; - } - return "Instance $Instance not found\n"; -} - - -sub ShowStats () { - ## Utility routine to show statistics - my($k) = 0; - my($p) = ''; - foreach my $self (@AllTies) { - next unless defined($self->{T}); - $p .= "ExpireLRU Statistics:\n" unless $k; - $k++; - - $p .= <{INSTANCE} - Cache Size: $self->{CACHESIZE} - Experimental Cache Size: $self->{TUNECACHESIZE} - Cache Hits: $self->{ch} - Cache Misses: $self->{cm} -Additional Cache Hits at Experimental Size: $self->{th} - Distribution : Hits -EOS - for (my $i = 0; $i < $self->{TUNECACHESIZE}; $i++) { - if ($i == $self->{CACHESIZE}) { - $p .= " ---- -----\n"; - } - $p .= sprintf(" %3d : %s\n", - $i, $self->{T}->[$i]); - } - } - return $p; -} - -=head1 NAME - -Memoize - Expiry plug-in for Memoize that adds LRU cache expiration - -=head1 SYNOPSIS - - use Memoize; - - memoize('slow_function', - TIE => [Memoize::ExpireLRU, - CACHESIZE => n, - ]); - -Note that one need not C this module. It will be found by the -Memoize module. - -The argument to CACHESIZE must be an integer. Normally, this is all -that is needed. Additional options are available: - - TUNECACHESIZE => m, - INSTANCE => 'descriptive_name', - TIE => '[DB_File, $filename, O_RDWR | O_CREATE, 0666]' - -=head1 DESCRIPTION - -For the theory of Memoization, please see the Memoize module -documentation. This module implements an expiry policy for Memoize -that follows LRU semantics, that is, the last n results, where n is -specified as the argument to the C parameter, will be -cached. - -=head1 PERFORMANCE TUNING - -It is often quite difficult to determine what size cache will give -optimal results for a given function. To aid in determining this, -ExpireLRU includes cache tuning support. Enabling this causes a -definite performance hit, but it is often useful before code is -released to production. - -To enable cache tuning support, simply specify the optional -C parameter with a size greater than that of the -C parameter. - -When the program exits, a set of statistics will be printed to -stderr. If multiple routines have been memoized, separate sets of -statistics are printed for each routine. The default names are -somewhat cryptic: this is the purpose of the C -parameter. The value of this parameter will be used as the identifier -within the statistics report. - -=head1 DIAGNOSTIC METHODS - -Two additional routines are available but not -exported. Memoize::ExpireLRU::ShowStats returns a string identical to -the statistics report printed to STDERR at the end of the program if -test caches have been enabled; Memoize::ExpireLRU::DumpCache takes the -instance name of a memoized function as a parameter, and returns a -string describing the current state of that instance. - -=head1 AUTHOR - -Brent B. Powers (B2Pi), Powers@B2Pi.com - -Copyright(c) 1999 Brent B. Powers. All rights reserved. This program -is free software, you may redistribute it and/or modify it under the -same terms as Perl itself. - -=head1 SEE ALSO - -Memoize - -=cut diff -Nru libmemoize-expirelru-perl-0.55/lib/Memoize/ExpireLRU.pm libmemoize-expirelru-perl-0.56/lib/Memoize/ExpireLRU.pm --- libmemoize-expirelru-perl-0.55/lib/Memoize/ExpireLRU.pm 1970-01-01 00:00:00.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/lib/Memoize/ExpireLRU.pm 2016-07-06 23:04:27.000000000 +0000 @@ -0,0 +1,406 @@ +########################################################################### +# File - ExpireLRU.pm +# Created 12 Feb, 2000, Brent B. Powers +# +# Purpose - This package implements LRU expiration. It does this by +# using a bunch of different data structures. Tuning +# support is included, but costs performance. +# +# ToDo - Test the further tie stuff +# +# Copyright(c) 2000 Brent B. Powers and B2Pi LLC +# +# You may copy and distribute this program under the same terms as +# Perl itself. +# +########################################################################### +package Memoize::ExpireLRU; +$Memoize::ExpireLRU::VERSION = '0.56'; +use 5.006; +use warnings; +use strict; +use AutoLoader qw(AUTOLOAD); +use Carp; + +our $DEBUG = 0; + +# Usage: memoize func , +# TIE => [ +# Memoize::ExpireLRU, +# CACHESIZE => n, +# TUNECACHESIZE => m, +# INSTANCE => IDString +# TIE => [...] +# ] + +############################################# +## +## This used to all be a bit more reasonable, but then it turns out +## that Memoize doesn't call FETCH if EXISTS returns true and it's in +## scalar context. Thus, everything really has to be done in the +## EXISTS code. Harumph. +## +############################################# + +our @AllTies; +our $EndDebug = 0; + +1; + +sub TIEHASH { + my ($package, %args, %cache, @index, @Tune, @Stats); + ($package, %args)= @_; + my($self) = bless \%args => $package; + $self->{CACHESIZE} or + croak "Memoize::ExpireLRU: CACHESIZE must be specified >0; aborting"; + $self->{TUNECACHESIZE} ||= 0; + delete($self->{TUNECACHESIZE}) unless $self->{TUNECACHESIZE}; + $self->{C} = \%cache; + $self->{I} = \@index; + defined($self->{INSTANCE}) or $self->{INSTANCE} = "$self"; + foreach (@AllTies) { + if ($_->{INSTANCE} eq $self->{INSTANCE}) { + croak "Memoize::ExpireLRU: Attempt to register the same routine twice; aborting"; + } + } + if ($self->{TUNECACHESIZE}) { + $EndDebug = 1; + for (my $i = 0; $i < $args{TUNECACHESIZE}; $i++) { + $Stats[$i] = 0; + } + $self->{T} = \@Stats; + $self->{TI} = \@Tune; + $self->{cm} = $args{ch} = $args{th} = 0; + + } + + if ($self->{TIE}) { + my($module, $modulefile, @opts, $rc, %tcache); + ($module, @opts) = @{$args{TIE}}; + $modulefile = $module . '.pm'; + $modulefile =~ s{::}{/}g; + eval { require $modulefile }; + if ($@) { + croak "Memoize::ExpireLRU: Couldn't load hash tie module `$module': $@; aborting"; + } + $rc = (tie %tcache => $module, @opts); + unless ($rc) { + croak "Memoize::ExpireLRU: Couldn't tie hash to `$module': $@; aborting"; + } + + ## Preload our cache + foreach (keys %tcache) { + $self->{C}->{$_} = $tcache{$_} + } + $self->{TiC} = \%tcache; + } + + push(@AllTies, $self); + return $self; +} + +sub EXISTS { + my($self, $key) = @_; + + $DEBUG and print STDERR " >> $self->{INSTANCE} >> EXISTS: $key\n"; + + if (exists $self->{C}->{$key}) { + my($t, $i);#, %t, %r); + + ## Adjust the positions in the index cache + ## 1. Find the old entry in the array (and do the stat's) + $i = _find($self->{I}, $self->{C}->{$key}->{t}, $key); + if (!defined($i)) { + print STDERR "Cache trashed (unable to find $key)\n"; + DumpCache($self->{INSTANCE}); + ShowStats(); + die "Aborting..."; + } + + ## 2. Remove the old entry from the array + $t = splice(@{$self->{I}}, $i, 1); + + ## 3. Update the timestamp of the new array entry, as + ## well as that in the cache + $self->{C}->{$key}->{t} = $t->{t} = time; + + ## 4. Store the updated entry back into the array as the MRU + unshift(@{$self->{I}}, $t); + + ## 5. Adjust stats + if (defined($self->{T})) { + $self->{T}->[$i]++ if defined($self->{T}); + $self->{ch}++; + } + + if ($DEBUG) { + print STDERR " Cache hit at $i"; + print STDERR " ($self->{ch})" if defined($self->{T}); + print STDERR ".\n"; + } + + return 1; + } else { + if (exists($self->{TUNECACHESIZE})) { + $self->{cm}++; + $DEBUG and print STDERR " Cache miss ($self->{cm}).\n"; + ## Ughhh. A linear search + my($i, $j); + for ($i = $j = $self->{CACHESIZE}; $i <= $#{$self->{T}}; $i++) { + next unless defined($self->{TI}) + && defined($self->{TI}->[$i- $j]) + && defined($self->{TI}->[$i - $j]->{k}) + && $self->{TI}->[$i - $j]->{k} eq $key; + $self->{T}->[$i]++; + $self->{th}++; + $DEBUG and print STDERR " TestCache hit at $i. ($self->{th})\n"; + splice(@{$self->{TI}}, $i - $j, 1); + return 0; + } + } else { + $DEBUG and print STDERR " Cache miss.\n"; + } + return 0; + } +} + +sub STORE { + my ($self, $key, $value) = @_; + $DEBUG and print STDERR " >> $self->{INSTANCE} >> STORE: $key $value\n"; + + my(%r, %t); + $t{t} = $r{t} = time; + $r{v} = $value; + $t{k} = $key; + + # Store the value into the hash + $self->{C}->{$key} = \%r; + ## As well as the tied cache, if it exists + $self->{TC}->{$key} = $value if defined($self->{TC}); + + # By definition, this item is the MRU, so add it to the beginning + # of the LRU queue. Since this is a STORE, we know it doesn't already + # exist. + unshift(@{$self->{I}}, \%t); + ## Update the tied cache + $self->{TC}->{$key} = $value if defined($self->{TC}); + + ## Do we have too many entries? + while (scalar(@{$self->{I}}) > $self->{CACHESIZE}) { + ## Chop off whatever is at the end + ## Get the key + $key = pop(@{$self->{I}}); + delete($self->{C}->{$key->{k}}); + delete($self->{TC}->{$key->{k}}) if defined($self->{TC}); + ## Throw it to the beginning of the test cache + unshift(@{$self->{TI}}, $key) if defined($self->{T}); + } + + ## Now, what about the Tuning Index + if (defined($self->{T})) { + if (scalar(@{$self->{TI}}) > $self->{TUNECACHESIZE} - $self->{CACHESIZE}) { + $#{$self->{TI}} = $self->{TUNECACHESIZE} - $self->{CACHESIZE} - 1; + } + } + + $value; +} + +sub FETCH { + my($self, $key) = @_; + + $DEBUG and print STDERR " >> $self->{INSTANCE} >> FETCH: $key\n"; + + return $self->{C}->{$key}->{v}; +} + +sub _find ( $$$ ) { + my($Aref, $time, $key) = @_; + my($t, $b, $n, $l); + + $t = $#{$Aref}; + $n = $b = 0; + $l = -2; + + while ($time != $Aref->[$n]->{t}) { + if ($time < $Aref->[$n]->{t}) { + $b = $n; + } else { + $t = $n; + } + if ($t <= $b) { + ## Trouble, we're out. + if ($Aref->[$t]->{t} == $time) { + $n = $t; + } elsif ($Aref->[$b]->{t} == $time) { + $n = $b; + } else { + ## Really big trouble + ## Complain loudly + print "Trouble\n"; + return undef; + } + } else { + $n = $b + (($t - $b) >> 1); + $n++ if $l == $n; + $l = $n; + } + } + ## Drop down in the array until the time isn't the time + while (($n > 0) && ($time == $Aref->[$n-1]->{t})) { + $n--; + } + while (($time == $Aref->[$n]->{t}) && ($key ne $Aref->[$n]->{k})) { + $n++; + } + if ($key ne $Aref->[$n]->{k}) { + ## More big trouble + print "More trouble\n"; + return undef; + } + return $n; +} + +END { + print STDERR ShowStats() if $EndDebug; +} + +__END__ + +sub DumpCache ( $ ) { + ## Utility routine to display the caches of the given instance + my($Instance, $self, $p) = shift; + foreach $self (@AllTies) { + + next unless $self->{INSTANCE} eq $Instance; + + $p = "$Instance:\n Cache Keys:\n"; + + foreach my $x (@{$self->{I}}) { + ## The cache is at $self->{C} (->{$key}) + $p .= " '$x->{k}'\n"; + } + $p .= " Test Cache Keys:\n"; + foreach my $x (@{$self->{TI}}) { + $p .= " '$x->{k}'\n"; + } + return $p; + } + return "Instance $Instance not found\n"; +} + + +sub ShowStats () { + ## Utility routine to show statistics + my($k) = 0; + my($p) = ''; + foreach my $self (@AllTies) { + next unless defined($self->{T}); + $p .= "ExpireLRU Statistics:\n" unless $k; + $k++; + + $p .= <{INSTANCE} + Cache Size: $self->{CACHESIZE} + Experimental Cache Size: $self->{TUNECACHESIZE} + Cache Hits: $self->{ch} + Cache Misses: $self->{cm} +Additional Cache Hits at Experimental Size: $self->{th} + Distribution : Hits +EOS + for (my $i = 0; $i < $self->{TUNECACHESIZE}; $i++) { + if ($i == $self->{CACHESIZE}) { + $p .= " ---- -----\n"; + } + $p .= sprintf(" %3d : %s\n", + $i, $self->{T}->[$i]); + } + } + return $p; +} + +=head1 NAME + +Memoize::ExpireLRU - Expiry plug-in for Memoize that adds LRU cache expiration + +=head1 SYNOPSIS + + use Memoize; + + memoize('slow_function', + TIE => [Memoize::ExpireLRU, + CACHESIZE => n, + ]); + +Note that one need not C this module. +It will be found by the L module. + +The argument to C must be an integer. +Normally, this is all that is needed. +Additional options are available: + + TUNECACHESIZE => m, + INSTANCE => 'descriptive_name', + TIE => '[DB_File, $filename, O_RDWR | O_CREATE, 0666]' + +=head1 DESCRIPTION + +For the theory of Memoization, please see the Memoize module +documentation. This module implements an expiry policy for Memoize +that follows LRU semantics, that is, the last n results, where n is +specified as the argument to the C parameter, will be +cached. + +=head1 PERFORMANCE TUNING + +It is often quite difficult to determine what size cache will give +optimal results for a given function. To aid in determining this, +ExpireLRU includes cache tuning support. Enabling this causes a +definite performance hit, but it is often useful before code is +released to production. + +To enable cache tuning support, simply specify the optional +C parameter with a size greater than that of the +C parameter. + +When the program exits, a set of statistics will be printed to +stderr. If multiple routines have been memoized, separate sets of +statistics are printed for each routine. The default names are +somewhat cryptic: this is the purpose of the C +parameter. The value of this parameter will be used as the identifier +within the statistics report. + +=head1 DIAGNOSTIC METHODS + +Two additional routines are available but not +exported. Memoize::ExpireLRU::ShowStats returns a string identical to +the statistics report printed to STDERR at the end of the program if +test caches have been enabled; Memoize::ExpireLRU::DumpCache takes the +instance name of a memoized function as a parameter, and returns a +string describing the current state of that instance. + + +=head1 SEE ALSO + +L + + +=head1 REPOSITORY + +L + + +=head1 AUTHOR + +Brent B. Powers (B2Pi), Powers@B2Pi.com + + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 1999 by Brent B. Powers. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff -Nru libmemoize-expirelru-perl-0.55/LICENSE libmemoize-expirelru-perl-0.56/LICENSE --- libmemoize-expirelru-perl-0.55/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/LICENSE 2016-07-06 23:04:27.000000000 +0000 @@ -0,0 +1,379 @@ +This software is copyright (c) 1999 by Brent B. Powers. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +Terms of the Perl programming language system itself + +a) the GNU General Public License as published by the Free + Software Foundation; either version 1, or (at your option) any + later version, or +b) the "Artistic License" + +--- The GNU General Public License, Version 1, February 1989 --- + +This software is Copyright (c) 1999 by Brent B. Powers. + +This is free software, licensed under: + + The GNU General Public License, Version 1, February 1989 + + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + 7. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19xx name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (a program to direct compilers to make passes + at assemblers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! + + +--- The Artistic License 1.0 --- + +This software is Copyright (c) 1999 by Brent B. Powers. + +This is free software, licensed under: + + The Artistic License 1.0 + +The Artistic License + +Preamble + +The intent of this document is to state the conditions under which a Package +may be copied, such that the Copyright Holder maintains some semblance of +artistic control over the development of the package, while giving the users of +the package the right to use and distribute the Package in a more-or-less +customary fashion, plus the right to make reasonable modifications. + +Definitions: + + - "Package" refers to the collection of files distributed by the Copyright + Holder, and derivatives of that collection of files created through + textual modification. + - "Standard Version" refers to such a Package if it has not been modified, + or has been modified in accordance with the wishes of the Copyright + Holder. + - "Copyright Holder" is whoever is named in the copyright or copyrights for + the package. + - "You" is you, if you're thinking about copying or distributing this Package. + - "Reasonable copying fee" is whatever you can justify on the basis of media + cost, duplication charges, time of people involved, and so on. (You will + not be required to justify it to the Copyright Holder, but only to the + computing community at large as a market that must bear the fee.) + - "Freely Available" means that no fee is charged for the item itself, though + there may be fees involved in handling the item. It also means that + recipients of the item may redistribute it under the same conditions they + received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications derived +from the Public Domain or from the Copyright Holder. A Package modified in such +a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided that +you insert a prominent notice in each changed file stating how and when you +changed that file, and provided that you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or an + equivalent medium, or placing the modifications on a major archive site + such as ftp.uu.net, or by allowing the Copyright Holder to include your + modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict with + standard executables, which must also be provided, and provide a separate + manual page for each non-standard executable that clearly documents how it + differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or executable +form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where to + get the Standard Version. + + b) accompany the distribution with the machine-readable source of the Package + with your modifications. + + c) accompany any non-standard executables with their corresponding Standard + Version executables, giving the non-standard executables non-standard + names, and clearly documenting the differences in manual pages (or + equivalent), together with instructions on where to get the Standard + Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this Package. You +may not charge a fee for this Package itself. However, you may distribute this +Package in aggregate with other (possibly commercial) programs as part of a +larger (possibly commercial) software distribution provided that you do not +advertise this Package as a product of your own. + +6. The scripts and library files supplied as input to or produced as output +from the programs of this Package do not automatically fall under the copyright +of this Package, but belong to whomever generated them, and may be sold +commercially, and may be aggregated with this Package. + +7. C or perl subroutines supplied by you and linked into this Package shall not +be considered part of this Package. + +8. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +The End + diff -Nru libmemoize-expirelru-perl-0.55/Makefile.PL libmemoize-expirelru-perl-0.56/Makefile.PL --- libmemoize-expirelru-perl-0.55/Makefile.PL 2000-03-09 04:10:36.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/Makefile.PL 2016-07-06 23:04:27.000000000 +0000 @@ -1,12 +1,57 @@ +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.037. +use strict; +use warnings; + +use 5.006; + use ExtUtils::MakeMaker; -# See lib/ExtUtils/MakeMaker.pm for details of how to influence -# the contents of the Makefile that is written. -WriteMakefile( - NAME => 'Memoize::ExpireLRU', - VERSION_FROM => 'ExpireLRU.pm', # finds $VERSION - PREREQ_PM => { Memoize => 0.52 , }, - dist => { - COMPRESS => 'gzip', - SUFFIX => '.gz', - }, - ); + +my %WriteMakefileArgs = ( + "ABSTRACT" => "Expiry plug-in for Memoize that adds LRU cache expiration", + "AUTHOR" => "Brent B. Powers ", + "CONFIGURE_REQUIRES" => { + "ExtUtils::MakeMaker" => 0 + }, + "DISTNAME" => "Memoize-ExpireLRU", + "EXE_FILES" => [], + "LICENSE" => "perl", + "MIN_PERL_VERSION" => "5.006", + "NAME" => "Memoize::ExpireLRU", + "PREREQ_PM" => { + "AutoLoader" => 0, + "Carp" => 0, + "strict" => 0, + "warnings" => 0 + }, + "TEST_REQUIRES" => { + "Memoize" => 0, + "vars" => 0 + }, + "VERSION" => "0.56", + "test" => { + "TESTS" => "t/*.t" + } +); + + +my %FallbackPrereqs = ( + "AutoLoader" => 0, + "Carp" => 0, + "ExtUtils::MakeMaker" => 0, + "Memoize" => 0, + "strict" => 0, + "vars" => 0, + "warnings" => 0 +); + + +unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { + delete $WriteMakefileArgs{TEST_REQUIRES}; + delete $WriteMakefileArgs{BUILD_REQUIRES}; + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; +} + +delete $WriteMakefileArgs{CONFIGURE_REQUIRES} + unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; + +WriteMakefile(%WriteMakefileArgs); diff -Nru libmemoize-expirelru-perl-0.55/MANIFEST libmemoize-expirelru-perl-0.56/MANIFEST --- libmemoize-expirelru-perl-0.55/MANIFEST 2000-03-09 04:14:41.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/MANIFEST 2016-07-06 23:04:27.000000000 +0000 @@ -1,6 +1,11 @@ +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.037. Changes -ExpireLRU.pm +LICENSE MANIFEST +META.json +META.yml Makefile.PL README -test.pl +dist.ini +lib/Memoize/ExpireLRU.pm +t/02-original.t diff -Nru libmemoize-expirelru-perl-0.55/META.json libmemoize-expirelru-perl-0.56/META.json --- libmemoize-expirelru-perl-0.55/META.json 1970-01-01 00:00:00.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/META.json 2016-07-06 23:04:27.000000000 +0000 @@ -0,0 +1,49 @@ +{ + "abstract" : "Expiry plug-in for Memoize that adds LRU cache expiration", + "author" : [ + "Brent B. Powers " + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 5.037, CPAN::Meta::Converter version 2.150005", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : 2 + }, + "name" : "Memoize-ExpireLRU", + "prereqs" : { + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : { + "AutoLoader" : "0", + "Carp" : "0", + "perl" : "5.006", + "strict" : "0", + "warnings" : "0" + } + }, + "test" : { + "requires" : { + "Memoize" : "0", + "vars" : "0" + } + } + }, + "release_status" : "stable", + "resources" : { + "homepage" : "https://github.com/neilb/Memoize-ExpireLRU", + "repository" : { + "type" : "git", + "url" : "https://github.com/neilb/Memoize-ExpireLRU.git", + "web" : "https://github.com/neilb/Memoize-ExpireLRU" + } + }, + "version" : "0.56" +} + diff -Nru libmemoize-expirelru-perl-0.55/META.yml libmemoize-expirelru-perl-0.56/META.yml --- libmemoize-expirelru-perl-0.55/META.yml 1970-01-01 00:00:00.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/META.yml 2016-07-06 23:04:27.000000000 +0000 @@ -0,0 +1,26 @@ +--- +abstract: 'Expiry plug-in for Memoize that adds LRU cache expiration' +author: + - 'Brent B. Powers ' +build_requires: + Memoize: '0' + vars: '0' +configure_requires: + ExtUtils::MakeMaker: '0' +dynamic_config: 0 +generated_by: 'Dist::Zilla version 5.037, CPAN::Meta::Converter version 2.150005' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: Memoize-ExpireLRU +requires: + AutoLoader: '0' + Carp: '0' + perl: '5.006' + strict: '0' + warnings: '0' +resources: + homepage: https://github.com/neilb/Memoize-ExpireLRU + repository: https://github.com/neilb/Memoize-ExpireLRU.git +version: '0.56' diff -Nru libmemoize-expirelru-perl-0.55/README libmemoize-expirelru-perl-0.56/README --- libmemoize-expirelru-perl-0.55/README 2000-03-09 04:07:38.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/README 2016-07-06 23:04:27.000000000 +0000 @@ -3,11 +3,22 @@ Memoize::ExpireLRU is a module that implements LRU expiration for Memoize. -To build and install this extension, simply chant: - perl Makefile.PL - make - make test - make install +You can read a nicely formatted version of the documentation for +this module online: + + https://metacpan.org/pod/Module::Info + + +You should be able to install this using your usual method for installing +modules from CPAN. If you don't have one, have a look at: + + http://www.cpan.org/modules/INSTALL.html Memoize::ExpireLRU requires Memoize version 0.52 or greater. + +Copyright (c) 1999 Brent B. Powers. All rights reserved. + +This program is free software, +you may redistribute it and/or modify it under the same terms as Perl itself. + diff -Nru libmemoize-expirelru-perl-0.55/t/02-original.t libmemoize-expirelru-perl-0.56/t/02-original.t --- libmemoize-expirelru-perl-0.55/t/02-original.t 1970-01-01 00:00:00.000000000 +0000 +++ libmemoize-expirelru-perl-0.56/t/02-original.t 2016-07-06 23:04:27.000000000 +0000 @@ -0,0 +1,231 @@ +#!/usr/local/bin/perl -w +########################################################################### +# File - test.pl +# Created 12 Feb, 2000, Brent B. Powers +# +# Purpose - test for Memoize::ExpireLRU +# +# ToDo - Test when tied to other module +# +# +########################################################################### +use strict; +use Memoize; + +my $n = 0; +use vars qw($dbg); +$dbg = 0; +$| = 1; + +print "1..46\n"; + +use Memoize::ExpireLRU; +++$n; +print "ok $n\n"; + +my %CALLS = (); +sub routine ( $ ) { + return shift; +} +sub routine3 ( $ ) { + return shift; +} + +my($flag) = 1; ## 1 gives routine2 as a list, 0 as a scalar +sub routine2 ( $ ) { + if ($flag) { + my($z) = shift; + return (1, $z); + } else { + return shift; + } +} + +sub show ( $ ) { + print "not " unless shift; + ++$n; + print "ok $n\n"; +} + +{ +tie my %cache, 'Memoize::ExpireLRU', + CACHESIZE => 4, + TUNECACHESIZE => 6, + INSTANCE => 'routine', + ; +memoize('routine', + SCALAR_CACHE => ['HASH' => \%cache], + LIST_CACHE => 'FAULT'); +} + +if ($flag) { + tie my %cache, 'Memoize::ExpireLRU', + CACHESIZE => 1, + TUNECACHESIZE => 5, + INSTANCE => 'routine2'; + memoize('routine2', + LIST_CACHE => ['HASH' => \%cache], + SCALAR_CACHE => 'FAULT',); +} else { + tie my %cache, 'Memoize::ExpireLRU', + CACHESIZE => 1, + TUNECACHESIZE => 5, + INSTANCE => 'routine2'; + memoize('routine2', + SCALAR_CACHE => ['HASH' => \%cache], + LIST_CACHE => 'FAULT'); +} + +{ +tie my %cache, 'Memoize::ExpireLRU', + CACHESIZE => 4, + INSTANCE => 'routine3'; +memoize('routine3', + SCALAR_CACHE => ['HASH' => \%cache], + LIST_CACHE => 'FAULT'); +} + +$Memoize::ExpireLRU::DEBUG = 1; +$Memoize::ExpireLRU::DEBUG = 0; +show(1); + +# 3--6 +## Fill the cache +for (0..3) { + show(routine($_) == $_); + $CALLS{$_} = $_; +} + + +# 7--10 +## Ensure that the return values were correct +for (keys %CALLS) { + show($CALLS{$_} == (0,1,2,3)[$_]); +} + +# 11--14 +## Check returns from the cache +for (0..3) { + show(routine($_) == $_); +} + +# 15--18 +## Make sure we can get each one of the array +foreach (0,2,0,0) { + show(routine($_) == $_); +} + +## Make sure we can get each one of the aray, where the timestamps are +## different +my($i); +for (0..3) { +# sleep(1); + $i = routine($_); +} + +# 19 +show(1); + +# 20-23 +for (0,2,0,0) { + show(routine($_) == $_); +} + +## Check getting a new one +## Force the order +for (3,2,1,0) { + $i = routine($_); +} + +# 24--25 +## Push off the last one, and ensure that the +## one we pushed off is really pushed off +for (4, 3) { + show(routine($_) == $_); +} + + +# 26--30 +## Play with the second function +## First, fill it +my(@a); +for (5,4,3,2,1,0) { + if ($flag) { + show((routine2($_))[1] == $_); + } else { + show($_ == routine2($_)); + } +} + + +## Now, hit each of them, in order +# 31 -- 35 +## Force at least one cache hit +if ($flag) { + @a = routine2(0); +} else { + routine2(0); +} + +for (1..4) { + if ($flag) { + show((routine2($_))[1] == $_); + } else { + show($_ == routine2($_)); + } +} + +## 36-44 +for (0,1,2,3,4,5,5,4,3) { + show($_ == routine3($_)); +} + +my($q) = < ['TIE', - 'Memoize::ExpireLRU', - CACHESIZE => 4, - TUNECACHESIZE => 6, - INSTANCE => 'routine', - ], - LIST_CACHE => 'FAULT'); - -if ($flag) { - memoize('routine2', - LIST_CACHE => ['TIE', - 'Memoize::ExpireLRU', - CACHESIZE => 1, - TUNECACHESIZE => 5, - INSTANCE => 'routine2', - ], - SCALAR_CACHE => 'FAULT',); -} else { - memoize('routine2', - SCALAR_CACHE => ['TIE', - 'Memoize::ExpireLRU', - CACHESIZE => 1, - TUNECACHESIZE => 5, - INSTANCE => 'routine2', - ], - LIST_CACHE => 'FAULT'); -} - -memoize('routine3', - SCALAR_CACHE => ['TIE', - 'Memoize::ExpireLRU', - CACHESIZE => 4, - INSTANCE => 'routine3', - ], - LIST_CACHE => 'FAULT'); - -$Memoize::ExpireLRU::DEBUG = 1; -$Memoize::ExpireLRU::DEBUG = 0; -show(1); - -# 3--6 -## Fill the cache -for (0..3) { - show(routine($_) == $_); - $CALLS{$_} = $_; -} - - -# 7--10 -## Ensure that the return values were correct -for (keys %CALLS) { - show($CALLS{$_} == (0,1,2,3)[$_]); -} - -# 11--14 -## Check returns from the cache -for (0..3) { - show(routine($_) == $_); -} - -# 15--18 -## Make sure we can get each one of the array -foreach (0,2,0,0) { - show(routine($_) == $_); -} - -## Make sure we can get each one of the aray, where the timestamps are -## different -my($i); -for (0..3) { -# sleep(1); - $i = routine($_); -} - -# 19 -show(1); - -# 20-23 -for (0,2,0,0) { - show(routine($_) == $_); -} - -## Check getting a new one -## Force the order -for (3,2,1,0) { - $i = routine($_); -} - -# 24--25 -## Push off the last one, and ensure that the -## one we pushed off is really pushed off -for (4, 3) { - show(routine($_) == $_); -} - - -# 26--30 -## Play with the second function -## First, fill it -my(@a); -for (5,4,3,2,1,0) { - if ($flag) { - show((routine2($_))[1] == $_); - } else { - show($_ == routine2($_)); - } -} - - -## Now, hit each of them, in order -# 31 -- 35 -## Force at least one cache hit -if ($flag) { - @a = routine2(0); -} else { - routine2(0); -} - -for (1..4) { - if ($flag) { - show((routine2($_))[1] == $_); - } else { - show($_ == routine2($_)); - } -} - -## 36-44 -for (0,1,2,3,4,5,5,4,3) { - show($_ == routine3($_)); -} - -my($q) = <