App-MonM-Notifier
view release on metacpan or search on metacpan
lib/App/MonM/Notifier/Store.pm view on Meta::CPAN
package App::MonM::Notifier::Store; # $Id: Store.pm 81 2022-09-16 10:21:57Z abalama $
use strict;
use utf8;
=encoding utf8
=head1 NAME
App::MonM::Notifier::Store - monotifier store class
=head1 VERSION
Version 1.02
=head1 SYNOPSIS
use App::MonM::Notifier::Store;
my $store = App::MonM::Notifier::Store->new(
dsn => "DBI:mysql:database=monotifier;host=mysql.example.com",
user => "username",
password => "password",
set => [
"RaiseError 0",
"PrintError 0",
"mysql_enable_utf8 1",
],
expires => 3600*24*7,
maxtime => 300,
);
die($store->error) if $store->error;
=head1 DESCRIPTION
DBI interface for monotifier store. This module provides store methods
=head2 new
my $store = App::MonM::Notifier::Store->new(
dsn => "DBI:mysql:database=monotifier;host=mysql.example.com",
user => "username",
password => "password",
set => [
"RaiseError 0",
"PrintError 0",
"mysql_enable_utf8 1",
],
expires => 3600*24*7,
maxtime => 300,
);
Creates DBI object
=over 8
=item B<expires>
Time in seconds of life of database record
=item B<maxtime>
Max time in seconds to sending one message
=back
=head2 cleanup
my $st = $store->cleanup;
Removes permanently queue entities based on how old they are
=head2 dequeue
my $st = $store->dequeue(
id => 1,
);
Dequeues the element by setting success status (STATUS_SENT)
=head2 delById
$store->delById($id) or die($store->error);
Delete record by id
=head2 dsn
my $dsn = $store->dsn;
Returns DSN string of current database connection
=head2 enqueue
$store->enqueue(
to => $user,
channel => $ch_name,
subject => $subject,
message => $message,
attributes => $ch, # Channel attributes
) or die($store->error);
Adds a new element at the end of the current queue
and returns queue element ID
=head2 error
( run in 0.907 second using v1.01-cache-2.11-cpan-39bf76dae61 )