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 # Select database (optional)
16 #database => 0,
17
18 # Choose your browseable fields
19 Index => 'uid mail',
20 };
21
22 # Use it like Apache::Session
23 my %session;
24 tie %session, 'Apache::Session::Browseable::Redis', $id, $args;
25 $session{uid} = 'me';
26 $session{mail} = 'me@me.com';
27 $session{unindexedField} = 'zz';
28 untie %session;
29
30 # Apache::Session::Browseable add some global class methods
31 #
32 # 1) search on a field (indexed or not)
33 my $hash = Apache::Session::Browseable::Redis->searchOn( $args, 'uid', 'me' );
34 foreach my $id (keys %$hash) {
35 print $id . ":" . $hash->{$id}->{mail} . "\n";
36 }
37
38 # 2) Parse all sessions
39 # a. get all sessions
40 my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions($args);
41
42 # b. get some fields from all sessions
43 my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions($args, 'uid', 'mail')
44
45 # c. execute something with datas from each session :
46 # Example : get uid and mail if mail domain is
47 my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions(
48 $args,
49 sub {
50 my ( $session, $id ) = @_;
51 if ( $session->{mail} =~ /mydomain.com$/ ) {
52 return { $session->{uid}, $session->{mail} };
53 }
54 }
55 );
56 foreach my $id (keys %$hash) {
57 print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n";
58 }
59
61 Apache::Session::browseable provides some class methods to manipulate
62 all sessions and add the capability to index some fields to make
63 research faster.
64
65 This module use either Redis::Fast or Redis.
66
68 Apache::Session
69
71 Xavier Guimard, <x.guimard@free.fr>
72
74 Copyright (C) 2009-2018 by Xavier Guimard
75
76 This library is free software; you can redistribute it and/or modify it
77 under the same terms as Perl itself, either Perl version 5.10.1 or, at
78 your option, any later version of Perl 5 you may have available.
79
80
81
82perl v5.36.0 2023-01-A1p9ache::Session::Browseable::Redis(3)