line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
############################################################################# |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Apache::Session::Memorycached |
4
|
|
|
|
|
|
|
# Apache persistent user sessions on the network with memcached |
5
|
|
|
|
|
|
|
# Copyright(c) eric german |
6
|
|
|
|
|
|
|
# Distribute under the Artistic License |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
############################################################################ |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Apache::Session::Memorycached; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
63702
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
86
|
|
13
|
2
|
|
|
2
|
|
10
|
use vars qw(@ISA $VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
150
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = '2.2.1'; |
16
|
|
|
|
|
|
|
@ISA = qw(Apache::Session); |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
2026
|
use Apache::Session; |
|
2
|
|
|
|
|
4114
|
|
|
2
|
|
|
|
|
62
|
|
19
|
2
|
|
|
2
|
|
1725
|
use Apache::Session::Generate::MD5; |
|
2
|
|
|
|
|
751
|
|
|
2
|
|
|
|
|
60
|
|
20
|
2
|
|
|
2
|
|
1267
|
use Apache::Session::Lock::Memorycached; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
51
|
|
21
|
2
|
|
|
2
|
|
1105
|
use Apache::Session::Store::Memorycached; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
534
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub populate { |
24
|
2
|
|
|
2
|
0
|
75
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
19
|
$self->{object_store} = new Apache::Session::Store::Memorycached $self; |
27
|
2
|
|
|
|
|
19
|
$self->{lock_manager} = new Apache::Session::Lock::Memorycached $self; |
28
|
2
|
|
|
|
|
31
|
$self->{generate} = \&Apache::Session::Generate::MD5::generate; |
29
|
2
|
|
|
|
|
7
|
$self->{validate} = \&Apache::Session::Generate::MD5::validate; |
30
|
2
|
|
|
|
|
7
|
$self->{serialize} = \&Apache::Session::Memorycached::none; |
31
|
2
|
|
|
|
|
5
|
$self->{unserialize} = \&Apache::Session::Memorycached::none; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
6
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub none { |
37
|
4
|
|
|
4
|
0
|
44
|
my $self = shift; |
38
|
4
|
|
|
|
|
6
|
my $session = shift; |
39
|
4
|
|
|
|
|
10
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
sub DESTROY { |
42
|
2
|
|
|
2
|
|
1577
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
10
|
$self->save; |
45
|
2
|
|
|
|
|
19
|
$self->{object_store}->close; |
46
|
2
|
|
|
|
|
15
|
$self->release_all_locks; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Apache::Session::Memorycached - An implementation of Apache::Session |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Apache::Session::Memorycached; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
tie %session, 'Apache::Session::Memorycached', $cookie, { |
63
|
|
|
|
|
|
|
'servers' => ["10.75.1.19:11211"], #all write operations |
64
|
|
|
|
|
|
|
'local' => ["localhost:11211"], #read-only operations |
65
|
|
|
|
|
|
|
'timeout' => '300' |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
tie %s, 'Apache::Session::Memorycached', undef, |
69
|
|
|
|
|
|
|
{servers => ['mymemcachedserver:port'], |
70
|
|
|
|
|
|
|
'timeout' => '300', |
71
|
|
|
|
|
|
|
'updateOnly' => 1 , |
72
|
|
|
|
|
|
|
'principal' => uid, |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
In order to optimize the network ,you can use a local memcached server. |
76
|
|
|
|
|
|
|
All read-only opération are sending fisrt at local server .If you need write ou rewrite data , the data is sending at the principal memcached sever and local cache too for synchronisation. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
note : 'updateOnly' => 1 just realize up-date operation not init operation. |
79
|
|
|
|
|
|
|
Init operation is use in order to book and lock the number session but it's not available in this module |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
'principal' => uid : this parameter is use to create reverse reference |
82
|
|
|
|
|
|
|
like this : MD5_hex(uid) => id_session in memcached server . By this it usefull to retrieve id_session from principal name . And add uid_MD5 => MD5_hex(uid) in main session . |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This module is an implementation of Apache::Session. It uses the memcached system backing |
91
|
|
|
|
|
|
|
store . You may specify servers (principal) and locals caches for locking in arguments to the constructor. See the example, and the documentation for Apache::Session::Store::Memorycached and Cache::Memcached . |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 REPLICATION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Now Apache::Session::Memorycahed inclues replication between memecached servers |
97
|
|
|
|
|
|
|
Two new components provide a replication service . |
98
|
|
|
|
|
|
|
First package is Apache::Session::MemcachedReplicator |
99
|
|
|
|
|
|
|
Second is Apache::Session::MemcachedClient |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
It's now possible to do replication master to slave or master to master |
102
|
|
|
|
|
|
|
see man pages and scripts . |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SOAP service |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Now Apache::Session::Memorycached inclues a SOAP service in order to set or |
108
|
|
|
|
|
|
|
get %session in any language . The SOAP service translates data in Perl hashes |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 Installation of SOAP service |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
All scripts are in scripts directory |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Put MemcachedSOAPClass.pm and MemcachedSOAP.cgi in the cgi-bin directory of your apache server with the appropriate right (x) . |
115
|
|
|
|
|
|
|
Change in MemcachedSOAP.cgi the memcached server address . |
116
|
|
|
|
|
|
|
(line 11 : $machine = 'ip.ip.ip.ip:11211'; ) |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Try the three scripts statTest.pl (first !) then getTest.pl finish with setTest.pl. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The lemonldap project (SSO under GPL) uses this module |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This module was written by eric german . |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Completed by Habib ZITOUNI and |
128
|
|
|
|
|
|
|
Hamza AISSAT |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
SOAP service is a contribution of Casimir ANTUNES . |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SEE ALSO |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L, L, |
135
|
|
|
|
|
|
|
L,L, |
136
|
|
|
|
|
|
|
L, L, L |