use Smart::Comments; sub foo ($) { my $arg = shift; state %cache; return $cache{$arg} if exists $cache{$arg}; my $result = ... something costly ...; ### Look MA! No hands! Really... $cache{$arg} = $result; }
In reply to Re: How to test caching?
by repellent
in thread How to test caching?
by JavaFan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |