X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=Tagtools.pm;h=371c056bb4a7ed1e4592e38c997bdef02d778621;hb=4ee27d9f44c03987eaa40a9324b3f4492c3703a0;hp=292e6e517a33c821e5f53bffd6efa2e3faea6a71;hpb=f2b33d6a43cde2f4e9c1170f3ae15a5cfb62d09e;p=memories.git diff --git a/Tagtools.pm b/Tagtools.pm index 292e6e5..371c056 100644 --- a/Tagtools.pm +++ b/Tagtools.pm @@ -1,4 +1,5 @@ package Tagtools; +use URI::Escape; use HTML::TagCloud; use Carp; use Cache::FileCache; @@ -17,9 +18,9 @@ sub import { *{$whence."::do_cached"} = sub { my ($self, $codeblock,$arg) = @_; my $key = 0+$codeblock; if ($arg) { $key .=":".encode_base64(freeze(\$arg)); } - my $c = $cache->get(0+$codeblock); return @$c if $c; + my $c = $cache->get($key); return @$c if $c; my @stuff = $codeblock->($arg); - $cache->set(0+$codeblock, [ @stuff ]); + $cache->set($key, [ @stuff ]); return @stuff; }; *{$whence."::_tagcloud"} = sub { @@ -53,7 +54,7 @@ sub import { return \@month; }; for my $thing (qw(tagcloud calendar)) { - *{$whence."::$thing"} = sub { shift->do_cached($thing, @_) } + *{$whence."::$thing"} = sub { shift->do_cached(\&{$whence."::_".$thing}, @_) } } }