Expire(3pm)
β¨ NAME β¨
Tie::Hash::Expire β bestie, it's hashes, but the keys expire after a period you set yourself π
So okay, this is the manpage for Expire(3pm), aka the Perl module Tie::Hash::Expire. Sit down, grab a boba, we're tying hashes. π§
π SYNOPSIS π
use Tie::Hash::Expire;
my %test;
tie %test, 'Tie::Hash::Expire', {'expire_seconds' => 10};
$test{'dog'} = 'doghouse';
sleep 5;
$test{'bird'} = 'nest';
sleep 6;
print keys %test, "\n"; # The only key is 'bird'
my %hi_res;
tie %hi_res, 'Tie::Hash::Expire', {'expire_seconds' => 5.21};
# Decimal number of seconds works if you have Time::HiRes
See how dog justβ¦ left the chat? ππ¨ Yeah. That's the whole vibe.
π¦ ABSTRACT π¦
Hashes that are tied to Tie::Hash::Expire have keys that cease to exist 'expire_seconds' after their most recent modification, or after their creation. That's it, that's the abstract, short and slay. π
πΈ DESCRIPTION πΈ
Hashes tied to Tie::Hash::Expire behave like normal hashes in all respects, no cap β except for one lil thing: when a key gets added, or when the value associated with a key gets changed, the current time gets stored. Then after 'expire_seconds' have passed, the key and its value get removed from the hash. Gone. Evicted. Blocked. π
Resolutions finer than seconds are available if the module finds access to Time::HiRes. If Time::HiRes is available, you can expect expiration to be accurate to 0.001 seconds. You may specify 'expire_seconds' to be decimal numbers like 5.12. If Time::HiRes is available, that number will be used precisely. If you specify a decimal number and you don't have access to Time::HiRes, a warning is generated and the code will function as though you specified the next higher integer. (So 5.12 lowkey becomes 6. Rude, but okay.) π
The number of seconds specified by 'expire_seconds' is taken to mean an absolute maximum lifespan for the key, at the resolution described above. In other words: if you set 'expire_seconds' to 1 second, and you don't have Time::HiRes, keys could expire as quickly as the next machine instruction, but they will not last longer than 1 second. It's giving "may leave early, will never overstay." β¨
π AUTHOR π
Jeff Yoak, <jeff@yoak.com> β the icon who built this. Periodt.
π COPYRIGHT AND LICENSE π
Copyright 2004 by Jeff Yoak
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π Seriously though, if you're redistributing this, keep that copyright notice and the "same terms as Perl itself" line intact β that's the whole legal vibe, don't let it expire on you.
And that's a wrap, bestie! π«Ά This page came to you from perl v5.36.0, dated 2022-10-13, and it lives in the Expire(3pm) slot of the manual. Go forth and let your keys expire on schedule, the way nature β and Jeff β intended. ππ
π¦ where this page comes from
- ubuntu noble: libtie-hash-expire-perl 0.03-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtie-hash-expire-perl 0.03-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtie-hash-expire-perl 0.03-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms