App-MonM-Notifier

 view release on metacpan or  search on metacpan

lib/App/MonM/Notifier/Store.pm  view on Meta::CPAN


    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

lib/App/MonM/Notifier/Store.pm  view on Meta::CPAN

use CTK::DBI;
use CTK::Util qw/ read_attributes touch /;
use CTK::ConfGenUtil;
use CTK::TFVals qw/ :ALL /;
use CTK::Serializer;

use App::MonM::Const;
use App::MonM::Util qw/ set2attr /;

use constant {
    EXPIRES     => 30*24*60*60, # 30 days max (how time to hold of messages)
    MAXTIME     => 300, # 5 min
    JSON_ATTRS  => [
            { # For serialize
                utf8 => 0,
                pretty => 1,
                allow_nonref => 1,
                allow_blessed => 1,
            },
            { # For deserialize
                utf8 => 0,

lib/App/MonM/Notifier/Store.pm  view on Meta::CPAN

    }
    return 1;
}

sub _sheduled_calc {
    my $t = shift; # Attempt number
    if ($t >= 0 and $t < 5)         { return 60         } # 1 min per 5 min (5 times)
    elsif ($t >= 5 and $t < 7)      { return 60*5       } # 5 min per 15 min (2 times)
    elsif ($t >= 7 and $t < 10)     { return 60*15      } # 15 min per 1 hour (3 times)
    elsif ($t >= 10 and $t < 33)    { return 60*60      } # 1 hour per day (23 times)
    elsif ($t >= 33 and $t < 39)    { return 60*60*24   } # 1 day per week (6 times)
    elsif ($t >= 39 and $t < 42)    { return 60*60*24*7 } # 1 week per month (3 times)
    return 60*60*24*30; # every 1 month
}

1;

__END__



( run in 1.305 second using v1.01-cache-2.11-cpan-7add2cbd662 )