Cataly...aching(3pm)

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

✨ NAME ✨

Catalyst::TraitFor::Model::DBIC::Schema::Caching β€” bestie, it's literally query caching support for Catalyst::Model::DBIC::Schema. That's the whole vibe. πŸ’…

(also it's a 3pm page, so it's Perl module documentation, iykyk)


🌸 SYNOPSIS 🌸

okay so here's how you set it up, no cap:

    __PACKAGE__->config({
        traits => ['Caching'],
        connect_info =>
            ['dbi:mysql:db', 'user', 'pass'],
    });

    $c->model('DB::Table')->search({ foo => 'bar' }, { cache_for => 18000 });

that's it. that's the whole thing. slay. 🫢


πŸ’– DESCRIPTION πŸ’–

So the way this works is it enables caching support using DBIx::Class::Cursor::Cached and Catalyst::Plugin::Cache. Two little icons doing all the heavy lifting.

For this to actually work tho β€” and this is important, don't skip it β€” Catalyst::Plugin::Cache must be configured and loaded. A possible configuration would look like this:

  <Plugin::Cache>
    <backend>
      class Cache::FastMmap
      unlink_on_exit 1
      share_file /tmp/myapp_share
    </backend>
  </Plugin::Cache>

Then, in your queries, you set the cache_for ResultSet attribute to the number of seconds you want the query results to be cached for, eg.:

  $c->model('DB::Table')->search({ foo => 'bar' }, { cache_for => 18000 });

yes bestie, 18000 seconds. go off. πŸ”₯


πŸŽ€ CONFIG PARAMETERS πŸŽ€

caching

Turn caching on or off, you can use:

    $c->model('DB')->caching(0);

lowkey the simplest switch ever. 0 means off, and honestly the vibes of turning it off when you need fresh data? immaculate. 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

  • Catalyst::Model::DBIC::Schema
  • DBIx::Class
  • Catalyst::Plugin::Cache
  • Cache::FastMmap
  • DBIx::Class::Cursor::Cached

go read all of them, they're iconic fr fr πŸ‘‘


🌟 AUTHOR 🌟

See "AUTHOR" in Catalyst::Model::DBIC::Schema and "CONTRIBUTORS" in Catalyst::Model::DBIC::Schema.

(not me writing it out twice, but the original says both so both you get πŸ’œ)


See "COPYRIGHT" in Catalyst::Model::DBIC::Schema.


⭐ LICENSE ⭐

This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.

basically: it's Perl-licensed, go forth and remix responsibly 🧚

and that's the whole page bestie, mwah πŸ’– This was perl v5.36.0, dated 2023-10-26, from the User Contributed Perl Documentation, page Cataly...aching(3pm). bestie behaviour honestly, periodt. πŸŽ€πŸŒΈ

πŸ“¦ where this page comes from