Catman...e::Hash(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay bestie, so Catmandu::Store::Hash β€” it's an in-memory store. that's the whole vibe. it lives in your RAM and it slays. ✨

this is the manual page for Catmandu::Store::Hash(3pm), straight out of the User Contributed Perl Documentation corner of the internet, and we're gonna go through every last crumb together. no skipping. πŸ’…


🌸 SYNOPSIS 🌸

here's the whole thing in action, copy-paste ready, literally exactly as it appears:

use Catmandu;

my $store = Catmandu->store('Hash');

my $obj1 = $store->bag->add({ name => 'Patrick' });

printf "obj1 stored as %s\n" , $obj1->{_id};

# Force an id in the store
my $obj2 = $store->bag->add({ _id => 'test123' , name => 'Nicolas' });

my $obj3 = $store->bag->get('test123');

$store->bag->delete('test123');

$store->bag->delete_all;

# All bags are iterators
$store->bag->each(sub { ... });
$store->bag->take(10)->each(sub { ... });

so yeah β€” you spin up a store, you add some stuff, you get it back, you delete it, you nuke it all, and then you iterate over the bags because all bags are iterators. it's giving very much "everything is a loop if you believe hard enough". πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

a Catmandu::Store::Hash is an in-memory Catmandu::Store. that means it's backed by a hash β€” for fast retrieval β€” and it's also combined with a doubly linked list for fast traversal.

so like... you get the lookups and the walking-through. both. at once. main character behaviour, honestly. πŸ‘‘


✨ METHODS ✨

πŸŽ€ new([init_data => [...] ])

makes you a brand new Catmandu::Store::Hash. and if you want, you can hand it an init_data option β€” that's an array ref of data β€” and it'll come pre-loaded, like a little snack pack of records. πŸ“

my $store = Catmandu->store('Hash', init_data => [
       { _id => 1, data => foo } ,
       { _id => 2, data => bar }
]);

# or in a catmandu.yml configuration file:

---
store:
   hash:
     package: Hash
     options:
        init_data:
           - _id: 1
             data: foo
           - _id: 2
             data: bar

yep β€” you can do it inline in Perl or in a catmandu.yml configuration file, whichever fits your mood that day. 🌈


πŸ’œ INHERITED METHODS πŸ’œ

the way that this class doesn't do everything alone... it's a whole family tree situation. 🧚

this Catmandu::Store implements:

  • Catmandu::Store
  • Catmandu::Droppable
  • Catmandu::Transactional

and each Catmandu::Bag inside this Catmandu::Store implements:

  • Catmandu::Bag
  • Catmandu::Droppable

so that's where all the extra powers come from. iykyk. πŸ’«


lowkey a reminder bestie: it's an in-memory store, so it's living in RAM and it's fast and it's adorable, but it's not out here persisting to disk on its own. that's just what "in-memory" means, and this page says it right up top. 🫢

perl v5.40.1 Β· 2026-01-24 β€” and that's the sign-off from the Catmandu::Store::Hash(3pm) girlies. go forth and hash. periodt. πŸ’–πŸŽ€πŸŒΈπŸ¦‹βœ¨

πŸ“¦ where this page comes from