The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Memorator::Backend::Mojo::Pg - backend for Mojo::Pg

SYNOPSIS

   # in typical usage, this class is used automatically
   use Minion;
   use Memorator;
   my $minion = Minion->new(Pg => 'postgresql://postgres@/test');
   my $memorator = Memorator->create(
      minion => $minion, # <-- this is it
      ...
   );

   # The "explicit way" might imply using different databases
   # for Minion and this class
   use Mojo::Pg;
   use Memorator::Backend::Mojo::Pg;
   my $pg = Mojo::Pg->new('postgresql://postgres@/test');
   my $mempg = Memorator::Backend::Mojo::Pg->new(
      mojodb => $pg,         # mandatory
      name   => 'whatever',  # mandatory
   );

   # ... then, for Memorator...
   use Memorator;
   my $memorator = Memorator->create(
      backend => $mempg, # <-- this is it
      ...
   );

DESCRIPTION

This class allows you to use Mojo::Pg as a backend for keeping the mapping between external identifiers and job identifiers. It heavily relies on Memorator::Backend, that is its parent class, so it inherits all of its methods while implementing "migration", that allows setting up the table in the database.

You don't generally need to use this class directly, as it is used behind the scenes automatically by Memorator when you set a Minion that relies upon Mojo::Pg. It's anyway good to have around if you need to do non-standard things, like e.g. use different database technologies for the Minion backend and Memorator backend.

METHODS

This class inherits all methods from Memorator::Backend, adding the following one.

migration

   my $text = $obj->migration;

get the text suitable to create the database table(s) via "migrations" in Mojo::Pg. It relies upon "table_name" in Memorator::Backend to set the name of the table to be created.

SEE ALSO

Memorator::Backend.

AUTHOR

Flavio Poletti <polettix@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2018 by Flavio Poletti <polettix@cpan.org>

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.