Text::...eCache(3pm)

πŸ“¦
version 2.23 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Text::MicroMason::ExecuteCache β€” the manual page bestie πŸ’–

okay so real talk, this is Text::MicroMason::ExecuteCache from the User Contributed Perl Documentation section of the manual, and its whole vibe is: Use a Cache for Template Results πŸŽ€


🌸 NAME 🌸

Text::MicroMason::ExecuteCache β€” Use a Cache for Template Results ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so do NOT use this class directly, bestie, that's not the move. Instead you pass its name in so it gets mixed in like a little friendship bracelet:

use Text::MicroMason;
my $mason = Text::MicroMason->new( -ExecuteCache );

Then you use the standard compile method to parse a template into a subroutine, iconic behaviour honestly:

my $subref = $mason->compile( text=>$template );
print $subref->( 'name'=>'Dave' );

and the way that the template does not have to be interpreted the second time?? because the results are cached?? we love a queen who remembers πŸ’…:

print $subref->( 'name'=>'Dave' ); # fast second time

but when you run it with different arguments, the template gets re-interpreted and the results get stored, no cap:

print $subref->( 'name'=>'Bob' ); # first time for Bob

print $subref->( 'name'=>'Bob' ); # fast second time for Bob

πŸ’– DESCRIPTION πŸ’–

It caches the output of templates. periodt. 🌈

okay but listen β€” you should not use this feature if your template code interacts with any external state, like making changes to an external data source, or obtaining values that will change in the future. like, genuinely don't. πŸ™ˆ (However!! you can still use the caching provided by Text::MicroMason::CompileCache. that one's fine. 🫢)

✨ Public Methods ✨

  • compile() β€” wraps each template that is compiled into a Perl subroutine in a memoizing closure. it's giving memory, it's giving efficiency πŸ‘‘

πŸŽ€ Supported Attributes πŸŽ€

  • execute_cache β€” defaults to an instance of Text::MicroMason::Cache::Simple. slay.

This module uses a simple cache interface that is widely supported: the only methods required are get($key) and set($key, $value). You can use the simple cache classes provided in the Text::MicroMason::Cache:: namespace, or you can select other caching modules on CPAN that support the interface described in Cache::Cache. so many options bestie, the freedom is real πŸ¦‹


⭐ SEE ALSO ⭐

  • For an overview of this templating framework, see Text::MicroMason. πŸ’œ
  • This is a mixin class intended for use with Text::MicroMason::Base.
  • For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe. πŸ“š

and that's the whole page bestie!! this was documented with perl v5.36.0, dated 2023-08-10, from Text::...eCache(3pm) β€” go forth and cache responsibly, ily, mwah πŸ’‹βœ¨πŸŽ€

πŸ“¦ where this page comes from