DBIx::...:Cached(3pm)

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

✨ NAME ✨

DBIx::Class::Cursor::Cached β€” it's a cursor class, bestie, and it comes with built-in caching support πŸ’– (this one lives in the 3pm manual section, iykyk)


🌸 SYNOPSIS 🌸

okay so here's the whole vibe, literally copy-paste ready:

my $schema = SchemaClass->connect(
  $dsn, $user, $pass, { cursor_class => 'DBIx::Class::Cursor::Cached' }
);

$schema->default_resultset_attributes({
  cache_object => Cache::FileCache->new({ namespace => 'SchemaClass' }),
});

my $rs = $schema->resultset('CD')->search(undef, { cache_for => 300 });

my @cds = $rs->all; # fills cache

$rs = $schema->resultset('CD')->search(undef, { cache_for => 300 });
  # refresh resultset

@cds = $rs->all; # uses cache, no SQL run

$rs->cursor->clear_cache; # deletes data from cache

@cds = $rs->all; # refills cache
no cap, that # uses cache, no SQL run line is the whole moment. the SQL just... doesn't run. iconic. πŸ‘‘

πŸ’… AUTHOR πŸ’…

Matt S Trout <mst@shadowcat.co.uk> β€” also findable at http://www.shadowcat.co.uk/ πŸ¦‹

Initial development sponsored by and (c) Takkle, Inc. 2007 ✨


πŸŽ€ LICENSE πŸŽ€

This library is free software under the same license as perl itself 🫢


and that's the whole page, babe β€” no crumbs left behind 🌈

source/version check: perl v5.38.2 πŸ“ and this was dated 2024-03-05 πŸ’œ so if you're reading this from the future, hi, hope the caching is still slaying πŸ’– bye bestie!! 🧚✨

πŸ“¦ where this page comes from