Timed_Expire work?
sub TIEHASH {
my($pack, $lifetime) = @_;
bless { l => $lifetime, c => {}, e => {} } => $pack;
}
sub STORE {
my ($self, $key, $newval) = @_;
$self->{e}{$key} = time + $self->{l};
$self->{c}{$key} = $newval;
}
sub EXISTS {
my ($self, $key) = @_;
return exists $self->{c}{$key}
&& $self->{e}{$key} > time;
}
sub FETCH {
my ($self, $key) = @_;
return $self->EXISTS($key) ? $self->{c}{$key} : undef;
} |
http://www.plover.com/~mjd/perl/yak/tie/ |
| Back to Users
Up to section index | ![]() |
Using tie to escape feature creep: - 5 Copyright © 2000 Mark-Jason Dominus |