Cache:...Expiry(3pm)
πΈ NAME πΈ
Cache::Simple::TimedExpiry β it's giving simple, time-expiring cache β¨ bestie it literally does what it says on the tin, an in-memory cache where the entries justβ¦ expire. iconic behavior honestly π
β¨ EXAMPLE β¨
okay so here's the whole vibe in one script, no cap:
package main;
use strict;
use warnings;
$,=' '; $|++;
use Cache::Simple::TimedExpiry;
my $h = Cache::Simple::TimedExpiry->new;
$h->set( DieQuick => "No duration!", 0);
print $h->elements;
do { $h->set($_,"Value of $_", 1); sleep 2;}
for qw(Have a nice day you little monkey);
print $h->elements; $h->dump; sleep 4; print $h->elements; $h->dump;
print time;
like, watch it set stuff, sleep, and watch the entries β¨vanishβ¨ in real time π¦
π new
Set up a brand new cache object π«Ά that's it, that's the whole job, and she ate.
β³ expire_after SECONDS
Set the cache's expiry policy so entries expire after SECONDS seconds. π°οΈ And here's the tea bestie β setting this changes the expiry policy for pre-existing cache entries AND for new ones, so don't think you're sneaking the old ones past her π
π has_key KEY
Returns true if the cache has an entry with the key KEY π simple as. Returns false otherwise, obviously, iykyk.
π fetch KEY
Returns the cache entry with key KEY. If there's no such entry it returns undef π (yes, the sad little nothing-value, we've all been there).
π‘ bonus: you can also call it as get β two names, one icon π«Ά
πΎ store KEY VALUE
Stores VALUE in the cache with accessor KEY. Expire it from the cache at or after EXPIRYTIME. π
π‘ bonus again: you can also call it as set β she's flexible like that β¨
π AUTHOR π
Jesse Vincent <jesse@bestpractical.com> β and some of the heavy lifting was designed by Robert Spier <rspier@pobox.com> π
Copyright 2004 Jesse Vincent <jesse@bestpractical.com> π
okay bestie that's the whole page, no gatekeeping π this was User Contributed Perl Documentation, running on perl v5.34.0, dated 2022-06-13 β go forth and let your cache entries expire gorgeously π¦β¨ mwah π
π¦ where this page comes from
- debian bookworm: libcache-simple-timedexpiry-perl 0.27-3.1
- debian trixie: libcache-simple-timedexpiry-perl 0.27-3.1
- ubuntu noble: libcache-simple-timedexpiry-perl 0.27-3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms