.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Expire 3pm" .TH Expire 3pm "2022-10-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Tie::Hash::Expire \- Hashes with keys that expire after a user\-set period. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Tie::Hash::Expire; \& \& my %test; \& tie %test, \*(AqTie::Hash::Expire\*(Aq, {\*(Aqexpire_seconds\*(Aq => 10}; \& \& $test{\*(Aqdog\*(Aq} = \*(Aqdoghouse\*(Aq; \& sleep 5; \& $test{\*(Aqbird\*(Aq} = \*(Aqnest\*(Aq; \& sleep 6; \& \& print keys %test, "\en"; # The only key is \*(Aqbird\*(Aq \& \& my %hi_res; \& tie %hi_res, \*(AqTie::Hash::Expire\*(Aq, {\*(Aqexpire_seconds\*(Aq => 5.21}; \& # Decimal number of seconds works if you have Time::HiRes .Ve .SH "ABSTRACT" .IX Header "ABSTRACT" Hashes tied to Tie::Hash::Expire have keys that cease to exist 'expire_seconds' after their most recent modification or their creation. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Hashes tied to Tie::Hash::Expire behave like normal hashes in all respects except that when a key is added or the value associated with a key is changed, the current time is stored, and after 'expire_seconds' the key and value are removed from the hash. .PP 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, this number will be used precisely. If you specify a decimal number and don't have access to Time::HiRes, a warning is generated and the code will function as though you specified the next higher integer. .PP 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 do not have Time::HiRes, keys could expire as quickly as the next machine instruction, but will not last longer than 1 second. .SH "AUTHOR" .IX Header "AUTHOR" Jeff Yoak, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright 2004 by Jeff Yoak .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.