Cataly...:Store(3pm)

πŸ“¦
version 0.12 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Catalyst::Plugin::Cache::Store β€” bestie, this is literally the glow-up guide on how to write a Cache store plugin ✨


πŸŽ€ SYNOPSIS πŸŽ€

okay so here's the whole vibe in one code block, no notes:

package Catalyst::Plugin::Cache::Store::Frobnicator;

sub setup_frobnicator_cache_backend {
    my ( $app, $name, $config ) = @_;

    ....

    $app->register_cache_backend( $name => $cache_object );
}

that's it. that's the whole thing. iconic πŸ’…


✨ DESCRIPTION ✨

so you wanna write a cache store plugin? say less 🫢 fr fr, all you need is to implement one method, and it follows a naming convention, periodt:

setup_<<lower case store name>>_cache_backend {

}

like, for example, setup_fastmmap_cache_backend for Catalyst::Plugin::Cache::Store::FastMmap 🌸

and then inside that method you call register_cache_backend. that's the moment. that's the main character energy right there πŸ‘‘

the method will get the backend name and configuration as its first and second arguments. yup, in that order, don't mix them up bestie 😭

lowkey the best part? all invocation of the setup methods will be automatic, based on the configuration. the plugin does the work, you just sit there looking pretty 🧚✨

but β€” and this is important β€” the plugin must be loaded by the user. no plugin load, no setup method, no slay. that part is on them πŸ’€

also, heads up: store plugins are only necessary if some configuration defaults that are catalyst specific need to be provided. if that sentence sounds like it's doing a lot, it's because it is πŸ™ˆ

for most cases, simply using a cache class instead of a plugin is sufficient. easy, breezy, done πŸ¦‹


okay that's the whole page, bestie!! πŸ’– this was documented in perl v5.34.0, dated 2022-06-09 β€” yeah, it's giving vintage, but she still eats 🌈⭐ πŸŽ€

πŸ“¦ where this page comes from