What about:
sub foo ($) { my $arg = shift; state %cache; if exists $cache{$arg} { print "Got that from the cache!\n"; return $cache{$arg} } print "Didn't find that in cache...\n"; my $result = ... something costly ...; $cache{$arg} = $result; return $result; }
In reply to Re: How to test caching?
by pileofrogs
in thread How to test caching?
by JavaFan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |