tie saves the day
sub memoize {
my ($f_name, %ARGS) = @_;
my $f_ref = get_reference($f_name);
my %cache;
tie %cache, @{$ARGS{TIE}} if exists $ARGS{TIE}; # !!!
# the rest exactly as before ...
# ...
} |
use DB_File; use Memoize; memoize 'function', TIE => ['DB_File', $filename, O_RDWR|O_CREAT]; |
TIEuse Timed_Expire; use Memoize; memoize 'function', TIE => [Timed_Expire, 1000]; |
| Forward to Custom Cache Managers
Back to Users Up to section index Up to Using tie to escape feature creep course index | ![]() |
Using tie to escape feature creep: - 5 Copyright © 2000 Mark-Jason Dominus |