Catman...:Multi(3pm)

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

πŸ’– Catmandu::Store::Multi πŸ’–

okay bestie, welcome to Catman...:Multi(3pm) β€” yes that's the manual page name, we're being fancy today ✨ this one lives in the User Contributed Perl Documentation section and it's literally the group chat of Perl storage.


πŸŽ€ NAME πŸŽ€

Catmandu::Store::Multi β€” a store that adds data to multiple stores at once. it's giving "one queen, many thrones" πŸ‘‘


✨ SYNOPSIS ✨

so here's the whole vibe, copy-paste ready, no cap:

# On the Command line

# Configure the Multi store with a catmandu.yml file
$ cat catmandu.yml
---
store:
  metadata1:
   package: DBI
   options:
      data_source: "DBI:mysql:database=catmandu"
  metadata2:
   package: ElasticSearch
   options:
       client: '1_0::Direct'
       index_name: catmandu
  multi:
   package: Multi
   options:
       stores:
           - metadata1
           - metadata2
...

# Add a YAML record to the multi store
$ catmandu import YAML to multi < data.yml

# Extract all the records from the multi store as YAML
$ catmandu export multi to YAML > data.yml

# In Perl
use Catmandu;

my $store = Catmandu->store('Multi' , stores [
    Catmandu->store('DBI', data_source => 'DBI:mysql:database=catmandu') ,
    Catmandu->store('ElasticSearch', client => '1_0::Direct', index_name => 'catmandu') ,
]);

$store->bag->each(sub {
    my $item = shift;

    printf "%s\n" , $item->{_id};
});

$store->bag->add({ _id => 1234 , foo => 'bar' , test => [qw(1 2 3 4)]});

my $item = $store->bag->get('1234');

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

like, look at her go πŸ¦‹ one store call, multiple backends, absolutely ate πŸ’…


🌸 DESCRIPTION 🌸

so Catmandu::Store::Multi is literally a combination of many Catmandu::Store-s acting as one single access point. one door, many rooms, main character energy fr fr πŸšͺ✨

and she's not doing her own thing either β€” the Multi store inherits all the methods from Catmandu::Store. periodt.

by default, the Multi store tries to update records in all configured backend stores. and importing, exporting, delete and drop? all of those get executed against all backend stores when possible 🌈 so yeah, she's a "tell everyone at once" kind of girlie.


πŸ’… METHODS πŸ’…

new(stores => [...])

create a new Catmandu::Store::Multi. πŸ‘‘

the "store" configuration parameter contains an array of references to Catmandu::Store-s, based on their name in a configuration file or instances. iykyk 🫢


🧚 INHERITED METHODS 🧚

this Catmandu::Store implements:

  • Catmandu::Store
  • Catmandu::Droppable

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

  • Catmandu::Bag
  • Catmandu::Droppable

she got it from her mama, and her mama, and her mama πŸ’œ iconic behaviour honestly.


πŸ’€ reminder bestie: she's writing to all the backends by default. that's not a drill, that's the whole point. no take-backs unless the backend says so.

sign-off time πŸŽ€

this page is from perl v5.40.1 and it's dated 2026-01-24, and the page name is Catman...:Multi(3pm) in case you forgot where you were. love that for us. go forth and multi-store, bestie πŸ’–βœ¨πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from