1Apache::Session::BrowseUasbelre:C:oRnetdriisb(u3t)ed PerAlpaDcohceu:m:eSnetsastiioonn::Browseable::Redis(3)
2
3
4
6 Apache::Session::Browseable::Redis - Add index and search methods to
7 Apache::Session::Redis
8
10 use Apache::Session::Browseable::Redis;
11
12 my $args = {
13 server => '127.0.0.1:6379',
14
15 # Choose your browseable fileds
16 Index => 'uid mail',
17 };
18
19 # Use it like Apache::Session
20 my %session;
21 tie %session, 'Apache::Session::Browseable::Redis', $id, $args;
22 $session{uid} = 'me';
23 $session{mail} = 'me@me.com';
24 $session{unindexedField} = 'zz';
25 untie %session;
26
27 # Apache::Session::Browseable add some global class methods
28 #
29 # 1) search on a field (indexed or not)
30 my $hash = Apache::Session::Browseable::Redis->searchOn( $args, 'uid', 'me' );
31 foreach my $id (keys %$hash) {
32 print $id . ":" . $hash->{$id}->{mail} . "\n";
33 }
34
35 # 2) Parse all sessions
36 # a. get all sessions
37 my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions();
38
39 # b. get some fields from all sessions
40 my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions('uid', 'mail')
41
42 # c. execute something with datas from each session :
43 # Example : get uid and mail if mail domain is
44 my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions(
45 sub {
46 my ( $session, $id ) = @_;
47 if ( $session->{mail} =~ /mydomain.com$/ ) {
48 return { $session->{uid}, $session->{mail} };
49 }
50 }
51 );
52 foreach my $id (keys %$hash) {
53 print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n";
54 }
55
57 Apache::Session::browseable provides some class methods to manipulate
58 all sessions and add the capability to index some fields to make
59 research faster.
60
62 Apache::Session
63
65 Xavier Guimard, <x.guimard@free.fr>
66
68 Copyright (C) 2009 by Xavier Guimard
69
70 This library is free software; you can redistribute it and/or modify it
71 under the same terms as Perl itself, either Perl version 5.10.1 or, at
72 your option, any later version of Perl 5 you may have available.
73
74
75
76perl v5.28.0 2018-07-A1p4ache::Session::Browseable::Redis(3)