line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Apache::Session::Store::Memcached; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
44441
|
use Cache::Memcached; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use strict; |
5
|
|
|
|
|
|
|
use vars qw($VERSION); |
6
|
|
|
|
|
|
|
$VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
|
|
|
|
|
|
my($class,$session) = @_; |
10
|
|
|
|
|
|
|
my $self; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %opts = ( |
13
|
|
|
|
|
|
|
servers => ( ref $session->{args}->{Servers} eq 'ARRAY' ) |
14
|
|
|
|
|
|
|
? $session->{args}->{Servers} : [ split(/\s+/,$session->{args}->{Servers}) ], |
15
|
|
|
|
|
|
|
no_rehash => $session->{args}->{NoRehash}, |
16
|
|
|
|
|
|
|
readonly => $session->{args}->{ReadOnly}, |
17
|
|
|
|
|
|
|
debug => $session->{args}->{Debug}, |
18
|
|
|
|
|
|
|
compress_threshold => $session->{args}->{CompressThreshold} || 10_000, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#use Data::Dumper; |
22
|
|
|
|
|
|
|
#print STDERR Dumper $session->{args}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $memd = new Cache::Memcached \%opts; |
25
|
|
|
|
|
|
|
$self->{cache} = $memd; |
26
|
|
|
|
|
|
|
bless $self,$class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub insert { |
30
|
|
|
|
|
|
|
my($self,$session) = @_; |
31
|
|
|
|
|
|
|
if ( $self->{cache}->get($session->{data}->{_session_id}) ) { |
32
|
|
|
|
|
|
|
die "Object already exists in the data store."; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
$self->{cache}->set($session->{data}->{_session_id},$session->{serialized}); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub update { |
38
|
|
|
|
|
|
|
my($self,$session) = @_; |
39
|
|
|
|
|
|
|
$self->{cache}->replace($session->{data}->{_session_id},$session->{serialized}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub materialize { |
43
|
|
|
|
|
|
|
my($self, $session) = @_; |
44
|
|
|
|
|
|
|
$session->{serialized} = $self->{cache}->get($session->{data}->{_session_id}) or die 'Object does not exist in data store.'; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub remove { |
48
|
|
|
|
|
|
|
my($self, $session) = @_; |
49
|
|
|
|
|
|
|
$self->{cache}->delete($session->{data}->{_session_id}); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__END__ |