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, or undef if 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 returning undef. 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 to set (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 underlying Cache::Object object 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 from remove only in that the cache object is left around, e.g. for retrieval by get_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) is month and m (lowercase) is minute. 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