Text::...eCache(3pm)

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

✨ Text::MicroMason::CompileCache β€” the manual page, bestie edition ✨

okay so this is Text::MicroMason::CompileCache, a lil mixin that hands your template compilation over to a cache so you're not re-parsing the same thing over and over like a clown. It lives in the User Contributed Perl Documentation, and honestly? It's giving efficiency. πŸ’…


🌸 NAME 🌸

Text::MicroMason::CompileCache β€” Use a Cache for Template Compilation. Yes that's the whole name. Short, sweet, iconic. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

Bestie, listen: don't use this class directly. Instead you pass its name in to be mixed in:

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

Then you use the standard compile and execute methods to parse and evaluate templates:

print $mason->execute( text=>$template, 'name'=>'Dave' );

And the second time around? The template does not have to be parsed again because it's cached. Obsessed. ✨

print $mason->execute( text=>$template, 'name'=>'Bob' );

Templates stored in files get cached too, and they stay cached until the file changes:

print $mason->execute( file=>"./greeting.msn", 'name'=>'Charles');

πŸ’– DESCRIPTION πŸ’–

πŸ’« Public Methods πŸ’«

  • compile() β€” this is just a caching wrapper around the normal compile() behavior. Same energy, but with memory. 🧠

πŸ¦‹ Supported Attributes πŸ¦‹

  • compile_cache_text β€” defaults to an instance of Text::MicroMason::Cache::Simple. You may pass in your own cache object if you're feeling main character. πŸ’…
  • compile_cache_file β€” defaults to an instance of Text::MicroMason::Cache::File. You may pass in your own cache object here too. No cap.

This module uses a simple cache interface that is widely supported: the only methods required are get($key) and set($key, $value). That's it. Two methods. Bare minimum slay. ✨

You can use the simple cache classes provided in the Text::MicroMason::Cache:: namespace, or you can go shopping on CPAN and pick other caching modules that support the interface described in Cache::Cache. Do your thing, bestie. πŸ›οΈ


πŸ”₯ 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, periodt. πŸ’– This was perl v5.36.0, dated 2023-08-10, and it ate, no crumbs. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from