| 1 | # Copyright Infomation | ||
| 2 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 3 | # Author : Dr. Ahmed Amin Elsheshtawy, Ph.D. | ||
| 4 | # Website: https://github.com/mewsoft/Nile, http://www.mewsoft.com | ||
| 5 | # Email : mewsoft@cpan.org, support@mewsoft.com | ||
| 6 | # Copyrights (c) 2014-2015 Mewsoft Corp. All rights reserved. | ||
| 7 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 8 | package Nile::Plugin::Redis; | ||
| 9 | |||
| 10 | our $VERSION = '0.55'; | ||
| 11 | our $AUTHORITY = 'cpan:MEWSOFT'; | ||
| 12 | |||
| 13 | =pod | ||
| 14 | |||
| 15 | =encoding utf8 | ||
| 16 | |||
| 17 | =head1 NAME | ||
| 18 | |||
| 19 | Nile::Plugin::Redis - Redis database server plugin for the Nile framework. | ||
| 20 | |||
| 21 | =head1 SYNOPSIS | ||
| 22 | |||
| 23 | # connect to Redis server | ||
| 24 | my $redis = $app->plugin->redis; | ||
| 25 | |||
| 26 | # store some data | ||
| 27 | $redis->set("Name"=>"Ahmed Amin Elsheshtawy Gouda"); | ||
| 28 | |||
| 29 | # get some data | ||
| 30 | my $name = $redis->get("Name"); | ||
| 31 | |||
| 32 | # check some data if exists | ||
| 33 | if ($redis->exists("Name")) {say "Exists"} | ||
| 34 | |||
| 35 | # delete some data | ||
| 36 | $redis->del("Name"); | ||
| 37 | |||
| 38 | =head1 DESCRIPTION | ||
| 39 | |||
| 40 | Nile::Plugin::Redis - Redis database server plugin for the Nile framework. | ||
| 41 | |||
| 42 | Returns L<Redis> object. All methods of the L<Redis> module are supported. | ||
| 43 | |||
| 44 | Plugin settings in th config file under C<plugin> section. | ||
| 45 | |||
| 46 | <plugin> | ||
| 47 | |||
| 48 | <redis> | ||
| 49 | <server>localhost:6379</server> | ||
| 50 | <sock></sock> | ||
| 51 | <password></password> | ||
| 52 | <name></name> | ||
| 53 | <reconnect>60</reconnect> | ||
| 54 | <every>1000000</every> | ||
| 55 | <encoding></encoding> | ||
| 56 | </redis> | ||
| 57 | |||
| 58 | </plugin> | ||
| 59 | |||
| 60 | =cut | ||
| 61 | |||
| 62 | use Nile::Plugin; | ||
| 63 | use Redis; | ||
| 64 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 65 | sub main { | ||
| 66 | my ($self, $arg) = @_; | ||
| 67 | my $app = $self->app; | ||
| 68 | my $setting = $self->setting(); | ||
| 69 | rebless => Redis->new(%{$setting}); | ||
| 70 | } | ||
| 71 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 72 | |||
| 73 | =pod | ||
| 74 | |||
| 75 | =head1 Bugs | ||
| 76 | |||
| 77 | This project is available on github at L<https://github.com/mewsoft/Nile>. | ||
| 78 | |||
| 79 | =head1 HOMEPAGE | ||
| 80 | |||
| 81 | Please visit the project's homepage at L<https://metacpan.org/release/Nile>. | ||
| 82 | |||
| 83 | =head1 SOURCE | ||
| 84 | |||
| 85 | Source repository is at L<https://github.com/mewsoft/Nile>. | ||
| 86 | |||
| 87 | =head1 SEE ALSO | ||
| 88 | |||
| 89 | See L<Nile> for details about the complete framework. | ||
| 90 | |||
| 91 | =head1 AUTHOR | ||
| 92 | |||
| 93 | Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org> | ||
| 94 | Website: http://www.mewsoft.com | ||
| 95 | |||
| 96 | =head1 COPYRIGHT AND LICENSE | ||
| 97 | |||
| 98 | Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com, | ||
| 99 | L<https://github.com/mewsoft/Nile>, L<http://www.mewsoft.com> | ||
| 100 | |||
| 101 | This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||
| 102 | |||
| 103 | =cut | ||
| 104 | |||
| 105 | 1; |