CC: | Tim Retout <tim [...] retout.co.uk> |
Subject: | Memoize::Storable: 'nstore' option not respected |
Date: | Tue, 12 Jun 2012 18:55:29 -0500 |
To: | bug-Memoize [...] rt.cpan.org |
From: | Jonathan Nieder <jrnieder [...] gmail.com> |
Hi,
Memoize(3perl) says:
tie my %cache => 'Memoize::Storable', $filename, 'nstore';
memoize 'function', SCALAR_CACHE => [HASH => \%cache];
Include the ‘nstore’ option to have the "Storable" database
written in ‘network order’. (See Storable for more details
about this.)
Unfortunately in practice, using the 'nstore' option does not have
that effect. For example:
git clone git://repo.or.cz/git.git
cd git
git checkout v1.7.10
make
cd t
./t9158-git-svn-mergeinfo.sh --debug
perl -MStorable -e '
print Storable::file_magic(
".git/svn/.caches/lookup_svn_merge.db")->{"netorder"};
'
prints 0 instead of 1.
Noticed by Tim Retout (thanks!). How about something like this patch?
diff --git i/cpan/Memoize/Memoize/Storable.pm w/cpan/Memoize/Memoize/Storable.pm
index 33e35b48..d049d8d3 100644
--- i/cpan/Memoize/Memoize/Storable.pm
+++ w/cpan/Memoize/Memoize/Storable.pm
@@ -55,7 +55,7 @@ sub DESTROY {
require Carp if $Verbose;
my $self= shift;
print STDERR "Memoize::Storable::DESTROY(@_)\n" if $Verbose;
- if ($self->{OPTIONS}{'nstore'}) {
+ if (exists $self->{OPTIONS}{'nstore'}) {
Storable::nstore($self->{H}, $self->{FILENAME});
} else {
Storable::store($self->{H}, $self->{FILENAME});