line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CHI::Driver::Cache::RedisDB; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
498
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
extends 'CHI::Driver'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
698
|
use Cache::RedisDB; |
|
1
|
|
|
|
|
89826
|
|
|
1
|
|
|
|
|
345
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'namespace_set_key' => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
default => sub { 'CHI-MANAGED-NAMESPACES' }, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub BUILD { |
19
|
2
|
|
|
2
|
0
|
2212
|
my ($self, $params) = @_; |
20
|
2
|
|
|
|
|
21
|
Cache::RedisDB->redis->sadd($self->namespace_set_key, $self->namespace); |
21
|
0
|
|
|
|
|
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub fetch { |
25
|
0
|
|
|
0
|
0
|
|
my ($self, $key) = @_; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return Cache::RedisDB->get($self->namespace, $key); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub store { |
31
|
0
|
|
|
0
|
0
|
|
my ($self, $key, $data, $expires_in) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my @to_set = ($self->namespace, $key, $data); |
34
|
0
|
0
|
|
|
|
|
push @to_set, $expires_in if defined $expires_in; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return Cache::RedisDB->set(@to_set); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub remove { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, $key) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return Cache::RedisDB->del($self->namespace, $key); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub clear { |
46
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my @keys = $self->get_keys; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
return (@keys) ? Cache::RedisDB->del($self->namespace, @keys) : 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_keys { |
54
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return @{Cache::RedisDB->keys($self->namespace, '*')}; |
|
0
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_namespaces { |
60
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return @{Cache::RedisDB->redis->smembers($self->namespace_set_key)}; |
|
0
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub flush_all { |
67
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
foreach my $ns ($self->get_namespaces) { |
70
|
0
|
0
|
|
|
|
|
if (my @keys = @{Cache::RedisDB->keys($ns, '*')}) { |
|
0
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
Cache::RedisDB->del($ns, @keys); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
|
return Cache::RedisDB->redis->del($self->namespace_set_key); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=encoding utf-8 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
CHI::Driver::Cache::RedisDB - CHI Driver for Cache::RedisDB |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
CHI->new(driver => 'Cache::RedisDB'); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
CHI::Driver::Cache::RedisDB is a simple wrapper around Cache::RedisDB |
93
|
|
|
|
|
|
|
to provide the common CHI interface. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Matt Miller E<lt>matt@inspire.comE<gt> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright 2017- Matt Miller |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
106
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SEE ALSO |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |