++ed by:
VOJ KLEE JONASS

3 PAUSE users
10 non-PAUSE users.

Nicolas Steenlant
and 17 contributors

NAME

Catmandu::Store::Multi - A store that adds data to multiple stores

SYNOPSIS

    # 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');

DESCRIPTION

The Catmandu::Store::Multi is a combination of many Catmandu::Store-s as one access point. The Multi store inherits all the methods from Catmandu::Store.

By default, the Multi store tries to update records in all configured backend stores. Importing, exporting, delete and drop will be executed against all backend stores when possible.

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.

INHERITED METHODS

This Catmandu::Store implements:

Catmandu::Store
Catmandu::Droppable

Each Catmandu::Bag in this Catmandu::Store implements:

Catmandu::Bag
Catmandu::Droppable

SEE ALSO

Catmandu::Store::File::Multi , Catmandu::Plugin::SideCar