HTML::...seCache(3pm)
π HTML::Mason::Cache::BaseCache β the base cache object, bestie π
okay so this is HTML::Mason::Cache::BaseCache, a Perl module (3pm, you know the vibe) and it's literally the blueprint every Mason cache implementation is built on. π«Ά
β¨ NAME β¨
HTML::Mason::Cache::BaseCache β Base cache object π
πΈ DESCRIPTION πΈ
This is the base module for all cache implementations used in Mason. Periodt. Every cache in Mason? Yeah, it's giving "descended from this one." π
It hands you a few extra methods on top of Cache::BaseCache from Dewitt Clinton's Cache::Cache package. So like, the classic stuff is already there, and this one just adds a lil extra sprinkle. β¨
And when you call $m->cache, the object you get back is an object of this class. That's the whole tea. π
π METHODS π
clear ()β Remove all values in the cache. Every single one. Gone. It's giving "factory reset but make it cache." πget (key, [%params])β Returns the value associated with key, orundefif it's non-existent or expired. π But bestie, it's been extended with these optional name/value parameters:busy_lock => durationβ if the value has expired, instead of yeeting it out of the cache, it sets its expiration time to the current time plus duration before returningundef. Why? Because this is used to prevent multiple processes from recomputing the same expensive value simultaneously. No cap, it's the anti-duplicate-work lock. π₯ The duration may be of any form acceptable toset(scroll down, it's there).expire_if => subβ if the value exists and has not expired, call sub with the cache object as a single parameter. If sub returns a true value, expire the value. That's it, that's the rule. β
get_object (key)β Returns the underlyingCache::Objectobject associated with key. The most useful methods on this object are:
$co->get_created_at(); # when was object stored in cache
$co->get_accessed_at(); # when was object last accessed
$co->get_expires_at(); # when does object expire
expire (key)β Expires the value associated with key, if it exists. Differs fromremoveonly in that the cache object is left around, e.g. for retrieval byget_object. So it's expired but still lurking. πremove (key)β Removes the cache object associated with key, if it exists. Poof. π¦set (key, data, [duration])β Associates data with key in the cache. duration indicates the time until the value should be erased. If duration is unspecified, the value will never expire by time. Immortal era. β
$expires_in may be a simple number of seconds, or a string of the form "[number] [unit]", e.g., "10 minutes". The valid units are s, second, seconds, sec, m, minute, minutes, min, h, hour, hours, d, day, days, w, week, weeks, M, month, months, y, year, and years. π
Heads up bestie:M(capital) ismonthandm(lowercase) isminute. Case matters, don't get got. π
and that's the whole page, no crumbs left β this was perl v5.38.2, dated 2024-03-05, from HTML::Mason::Cache::BaseCache(3pm). mwah, go cache something iconic πβ¨
π¦ where this page comes from
- debian trixie: libhtml-mason-perl 1:1.60-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-mason-perl 1:1.60-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-mason-perl 1:1.60-2 Β· 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