line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cache::Memcached::Tie; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
37637
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
14
|
use 5.8.0; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
48
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1167
|
use Cache::Memcached::Fast; |
|
1
|
|
|
|
|
7252
|
|
|
1
|
|
|
|
|
42
|
|
8
|
1
|
|
|
1
|
|
10
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
9
|
|
|
|
|
|
|
$VERSION = '0.09'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1125
|
use fields qw(default_expire_seconds); |
|
1
|
|
|
|
|
1807
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub TIEHASH{ |
14
|
1
|
|
|
1
|
|
6562
|
my ($package, $default_expire_seconds, @params) = @_; |
15
|
1
|
|
|
|
|
3
|
my $self = {}; |
16
|
1
|
|
|
|
|
4
|
bless $self, $package; |
17
|
1
|
|
|
|
|
8
|
my $memd = Cache::Memcached::Fast->new(@params); |
18
|
1
|
|
|
|
|
120091
|
$self->{'memd'} = $memd; |
19
|
1
|
|
|
|
|
4
|
$self->{'default_expire_seconds'} = $default_expire_seconds; |
20
|
1
|
|
|
|
|
8
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub memd { |
24
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
25
|
1
|
|
|
|
|
1131
|
return $self->{memd}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub STORE{ |
29
|
0
|
|
|
0
|
|
|
my ($self, $key, $value) = @_; |
30
|
0
|
|
|
|
|
|
$self->memd->set($key, $value, $self->{'default_expire_seconds'}); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Check for the existence of a value - same as fetch, but sadly this is |
34
|
|
|
|
|
|
|
# necessary for when the hash is used by libraries that need EXISTS |
35
|
|
|
|
|
|
|
# functionality |
36
|
|
|
|
|
|
|
sub EXISTS { |
37
|
0
|
|
|
0
|
|
|
my ($self, $key) = @_; |
38
|
0
|
|
|
|
|
|
my $val = $self->FETCH($key); |
39
|
0
|
|
|
|
|
|
return defined($val); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Returns value or hashref (key=>$value) |
43
|
|
|
|
|
|
|
sub FETCH { |
44
|
0
|
|
|
0
|
|
|
my $self=shift; |
45
|
0
|
|
|
|
|
|
my @keys=split "\x1C", shift; # Some hack for multiple keys |
46
|
0
|
|
|
|
|
|
my $val; |
47
|
0
|
0
|
|
|
|
|
if (@keys==1){ |
48
|
0
|
|
|
|
|
|
$val = $self->memd->get($keys[0]); |
49
|
|
|
|
|
|
|
} else { |
50
|
0
|
|
|
|
|
|
$val = $self->memd->get_multi(@keys); |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
return $val; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub DELETE{ |
56
|
0
|
|
|
0
|
|
|
my $self=shift; |
57
|
0
|
|
|
|
|
|
my $key=shift; |
58
|
0
|
|
|
|
|
|
$self->memd->delete($key); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub UNTIE{ |
62
|
0
|
|
|
0
|
|
|
my $self=shift; |
63
|
0
|
|
|
|
|
|
$self->disconnect_all(); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub CLEAR{ |
67
|
0
|
|
|
0
|
|
|
my $self=shift; |
68
|
0
|
|
|
|
|
|
$self->memd->flush_all(); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__END__ |