Nile/Plugin/Cache/Redis.pm untested

filter: Statementstmt 0.0% 0 / 13 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 17 CC 1 SCAR 6.9
CC
1
Cov
0%
main
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
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::Cache::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::Cache::Redis - Cache plugin for the Nile framework using Redis.
20  
21 =head1 SYNOPSIS
22
23 # get Cache::Redis object
24 my $cache = $app->plugin("Cache::Redis");
25
26 $cache->set("fullname", "Ahmed Amin Elsheshtawy");
27  
28 $cache->get("fullname");
29  
30 $cache->remove("fullname");
31  
32 =head1 DESCRIPTION
33
34 Nile::Plugin::Cache::Redis - Cache plugin for the Nile framework using Redis.
35  
36 Returns the L<Cache::Redis> object. All methods of L<Cache::Redis> are supported.
37  
38 Plugin settings in th config file under C<plugin> section.
39  
40 <plugin>
41  
42 <cache_redis>
43 <server>localhost:6379</server>
44 <namespace>cache:</namespace>
45 <default_expires_in>2592000</default_expires_in>
46 </cache_redis>
47  
48 </plugin>
49  
50 =cut
51  
52 use Nile::Plugin;
53 use Cache::Redis;
54 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55 =head2 set()
56  
57 $cache->set($key, $value, $expire)
58  
59 Set a stuff to cache.
60  
61 =head2 set_multi()
62  
63 $cache->set_multi([$key, $value, $expire], [$key, $value])
64  
65 Set multiple stuffs to cache. stuffs is array reference.
66  
67 =head2 get()
68  
69 my $stuff = $cache->get($key)
70  
71 Get a stuff from cache.
72  
73 =head2 get_multi()
74
75 my $res = $cache->get_multi(@keys)
76  
77 Get multiple stuffs as hash reference from cache. @keys should be array. A key is not stored on cache don't be contain $res.
78  
79 =head2 remove()
80  
81 $cache->remove($key)
82
83 Remove stuff of key from cache.
84  
85 =head2 get_or_set()
86  
87 $cache->get_or_set($key, $code, $expire)
88  
89 Get a cache value for $key if it's already cached. If it's not cached then, run $code and cache $expiration seconds and return the value.
90  
91 =head2 nowait_push()
92
93 $cache->nowait_push
94  
95 Wait all response from Redis. This is intended for $cache->nowait.
96  
97 =cut
98  
99 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100 sub main {
101 my ($self, $arg) = @_;
102 my $app = $self->app;
103 my $setting = $self->setting();
104 rebless => Cache::Redis->new(%{$setting});
105 }
106 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107  
108 =pod
109  
110 =head1 Bugs
111  
112 This project is available on github at L<https://github.com/mewsoft/Nile>.
113  
114 =head1 HOMEPAGE
115  
116 Please visit the project's homepage at L<https://metacpan.org/release/Nile>.
117  
118 =head1 SOURCE
119  
120 Source repository is at L<https://github.com/mewsoft/Nile>.
121  
122 =head1 SEE ALSO
123  
124 See L<Nile> for details about the complete framework.
125  
126 =head1 AUTHOR
127  
128 Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org>
129 Website: http://www.mewsoft.com
130  
131 =head1 COPYRIGHT AND LICENSE
132  
133 Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com,
134 L<https://github.com/mewsoft/Nile>, L<http://www.mewsoft.com>
135  
136 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
137  
138 =cut
139  
140 1;