| 1 | package Catalyst::Model::Redis; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use base 'Catalyst::Model'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | our $VERSION = "0.02"; | |
| 8 | 2 | $VERSION = eval $VERSION; | |
| 9 | |||
| 10 | 2 | ▶ | use MRO::Compat; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 2 | ▶ | use mro 'c3'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 2 | ▶ | use RedisDB; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | =head1 NAME | ||
| 15 | |||
| 16 | Catalyst::Model::Redis - Redis Model Class | ||
| 17 | |||
| 18 | =head1 VERSION | ||
| 19 | |||
| 20 | 0.01 | ||
| 21 | |||
| 22 | =head1 SYNOPSIS | ||
| 23 | |||
| 24 | # use helper to add model | ||
| 25 | create model Redis Redis server port password | ||
| 26 | |||
| 27 | # lib/MyApp/Model/Redis.pm | ||
| 28 | package MyApp::Model::Redis; | ||
| 29 | use parent "Catalyst::Model::Redis"; | ||
| 30 | |||
| 31 | __PACKAGE__->config( | ||
| 32 | host => 'localhost', | ||
| 33 | port => 6379, | ||
| 34 | database => 3, | ||
| 35 | password => 'secret', | ||
| 36 | ); | ||
| 37 | |||
| 38 | 1; | ||
| 39 | |||
| 40 | # in controller | ||
| 41 | my $redis = $c->model('Redis')->redis; | ||
| 42 | |||
| 43 | =head1 DESCRIPTION | ||
| 44 | |||
| 45 | This module implements Redis model class for Catalyst. | ||
| 46 | |||
| 47 | =head1 METHODS | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | =head2 $self->new | ||
| 52 | |||
| 53 | Initializes L<RedisDB> object | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | 0 | ▶ | sub new { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 58 | 0 | my $self = shift->next::method(@_); | |
| 59 | 0 | my $c = shift; | |
| 60 | $self->{redis} = RedisDB->new( | ||
| 61 | 0 | map { $_ => $self->{$_} } qw(host port path database password lazy timeout utf8), | |
| 62 | ); | ||
| 63 | 0 | return $self; | |
| 64 | } | ||
| 65 | |||
| 66 | =head2 $self->redis | ||
| 67 | |||
| 68 | Returns the L<RedisDB> object | ||
| 69 | |||
| 70 | =cut | ||
| 71 | |||
| 72 | 0 | ▶ | sub redis { |
|
Subroutine
redis: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 73 | 0 | shift->{redis}; | |
| 74 | } | ||
| 75 | |||
| 76 | 2 | 1; | |
| 77 | |||
| 78 | __END__ | ||