| 1 | package Web::Session::Cassandra; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 3 | ▶ | use Apache::Session; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | ▶ | use Apache::Session::Lock::Null; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use Web::Session::Store::Cassandra; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use Web::Session::Generate::SHA256; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use Web::Session::Serialize::JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Web::Session::DBI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 3 | our $VERSION = '1.0.0'; | |||||||||
| 13 | 3 | our @ISA = qw(Web::Session::DBI Apache::Session); | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub populate { | ||||||||
|
Subroutine
populate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 16 | 0 | my $self = shift; | |||||||||
| 17 | |||||||||||
| 18 | $self->{object_store} = | ||||||||||
| 19 | 0 | new Web::Session::Store::Cassandra $self; | |||||||||
| 20 | 0 | $self->{lock_manager} = new Apache::Session::Lock::Null $self; | |||||||||
| 21 | 0 | $self->{generate} = \&Web::Session::Generate::SHA256::generate; | |||||||||
| 22 | 0 | $self->{validate} = \&Web::Session::Generate::SHA256::validate; | |||||||||
| 23 | 0 | $self->{serialize} = \&Web::Session::Serialize::JSON::serialize; | |||||||||
| 24 | 0 | $self->{unserialize} = \&Web::Session::Serialize::JSON::unserialize; | |||||||||
| 25 | |||||||||||
| 26 | 0 | return $self; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | # CQL can't run the SQL comparisons of DBI.pm: read all sessions and compare | ||||||||||
| 30 | # in Perl. As with other backends, sessions without the field are skipped | ||||||||||
| 31 | 4 | ▶ | sub searchLt { | ||||||||
|
Subroutine
searchLt: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 32 | 4 | my ( $class, $args, $selectField, $value, @fields ) = @_; | |||||||||
| 33 | 4 | $value = $class->_checkSearchValue( '<', $value ); | |||||||||
| 34 | 4 | ▶ | return {} unless ( defined $value ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | return $class->_searchByTest( $args, $selectField, | ||||||||||
| 36 | 3 | ▶ | sub { defined( $_[0] ) and $_[0] < $value }, @fields ); | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 4 | ▶ | sub searchGt { | ||||||||
|
Subroutine
searchGt: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 40 | 4 | my ( $class, $args, $selectField, $value, @fields ) = @_; | |||||||||
| 41 | 4 | $value = $class->_checkSearchValue( '>', $value ); | |||||||||
| 42 | 4 | ▶ | return {} unless ( defined $value ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | return $class->_searchByTest( $args, $selectField, | ||||||||||
| 44 | 3 | ▶ | sub { defined( $_[0] ) and $_[0] > $value }, @fields ); | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 3 | 1; | |||||||||
| 48 | |||||||||||
| 49 | =pod | ||||||||||
| 50 | |||||||||||
| 51 | =head1 NAME | ||||||||||
| 52 | |||||||||||
| 53 | Web::Session::Cassandra - Apache::Session backend to store | ||||||||||
| 54 | sessions in a Cassadra database. | ||||||||||
| 55 | |||||||||||
| 56 | =head1 SYNOPSIS | ||||||||||
| 57 | |||||||||||
| 58 | use Web::Session::Cassandra; | ||||||||||
| 59 | |||||||||||
| 60 | my $args = { | ||||||||||
| 61 | DataSource => 'dbi:Cassandra:host=localhost;keyspace=llng', | ||||||||||
| 62 | UserName => $db_user, | ||||||||||
| 63 | Password => $db_pass, | ||||||||||
| 64 | |||||||||||
| 65 | # Choose your browseable fileds | ||||||||||
| 66 | Index => '_whatToTrace _session_kind _utime iAddr', | ||||||||||
| 67 | }; | ||||||||||
| 68 | |||||||||||
| 69 | # Use it like Apache::Session | ||||||||||
| 70 | my %session; | ||||||||||
| 71 | tie %session, 'Web::Session::Cassandra', $id, $args; | ||||||||||
| 72 | $session{uid} = 'me'; | ||||||||||
| 73 | $session{mail} = 'me@me.com'; | ||||||||||
| 74 | $session{unindexedField} = 'zz'; | ||||||||||
| 75 | untie %session; | ||||||||||
| 76 | |||||||||||
| 77 | =head1 DESCRIPTION | ||||||||||
| 78 | |||||||||||
| 79 | Web::Session::Cassandra is an implementation of Apache::Session | ||||||||||
| 80 | for Cassandra database. | ||||||||||
| 81 | |||||||||||
| 82 | =head1 SCHEMA | ||||||||||
| 83 | |||||||||||
| 84 | To use this module, you will need at least these columns in a table | ||||||||||
| 85 | called 'sessions': | ||||||||||
| 86 | |||||||||||
| 87 | id text | ||||||||||
| 88 | a_session text | ||||||||||
| 89 | |||||||||||
| 90 | To create this schema, you can execute this command using cqlsh: | ||||||||||
| 91 | |||||||||||
| 92 | CREATE TABLE sessions ( | ||||||||||
| 93 | id text PRIMARY KEY, | ||||||||||
| 94 | a_session text | ||||||||||
| 95 | ); | ||||||||||
| 96 | |||||||||||
| 97 | =head1 CONFIGURATION | ||||||||||
| 98 | |||||||||||
| 99 | The module must know what datasource, username, and password to use when | ||||||||||
| 100 | connecting to the database. These values can be set using the options hash | ||||||||||
| 101 | (see Apache::Session documentation). The options are DataSource, UserName, | ||||||||||
| 102 | and Password. | ||||||||||
| 103 | |||||||||||
| 104 | Example: | ||||||||||
| 105 | |||||||||||
| 106 | tie %hash, 'Apache::Session::Cassandra', $id, { | ||||||||||
| 107 | DataSource => 'dbi:Cassandra:host=localhost;keyspace=llng', | ||||||||||
| 108 | UserName => 'database_user', | ||||||||||
| 109 | Password => 'K00l' | ||||||||||
| 110 | }; | ||||||||||
| 111 | |||||||||||
| 112 | Instead, you may pass in an already-opened DBI handle to your database. | ||||||||||
| 113 | |||||||||||
| 114 | tie %hash, 'Apache::Session::Cassandra', $id, { | ||||||||||
| 115 | Handle => $dbh | ||||||||||
| 116 | }; | ||||||||||
| 117 | |||||||||||
| 118 | =head1 searchLt() AND searchGt() | ||||||||||
| 119 | |||||||||||
| 120 | They take the same arguments and return the same data as searchOn(): sessions | ||||||||||
| 121 | whose field is lower (or greater) than the given value, which is excluded. The | ||||||||||
| 122 | value must be a number (C<12>, C<-12> or C<12.5>): otherwise nothing is | ||||||||||
| 123 | returned and an error is printed on STDERR. Spaces around the value are | ||||||||||
| 124 | ignored. | ||||||||||
| 125 | |||||||||||
| 126 | They read all sessions and compare fields in Perl: a non-numeric field value | ||||||||||
| 127 | is compared as 0, or as its numeric prefix. | ||||||||||
| 128 | |||||||||||
| 129 | Sessions without the field are never returned, as with the other backends of | ||||||||||
| 130 | this distribution. This differs from the Perl fallback of Lemonldap::NG, | ||||||||||
| 131 | where a missing field is compared as 0. | ||||||||||
| 132 | |||||||||||
| 133 | The connection is kept open between sessions. Set C<noreuse =E<gt> 1> to open | ||||||||||
| 134 | and close one for each session, see L<Web::Session/"PERSISTENT DATABASE CONNECTIONS">. | ||||||||||
| 135 | |||||||||||
| 136 | =head1 SEE ALSO | ||||||||||
| 137 | |||||||||||
| 138 | L<Apache::Session>, L<Apache::Session::DBI> | ||||||||||
| 139 | |||||||||||
| 140 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 141 | |||||||||||
| 142 | =encoding utf8 | ||||||||||
| 143 | |||||||||||
| 144 | Copyright (C): | ||||||||||
| 145 | |||||||||||
| 146 | =over | ||||||||||
| 147 | |||||||||||
| 148 | =item 2009-2026 by Xavier Guimard | ||||||||||
| 149 | |||||||||||
| 150 | =item 2013-2025 by Clément Oudot | ||||||||||
| 151 | |||||||||||
| 152 | =item 2019-2025 by Maxime Besson | ||||||||||
| 153 | |||||||||||
| 154 | =item 2013-2025 by Worteks | ||||||||||
| 155 | |||||||||||
| 156 | =item 2023-2026 by Linagora | ||||||||||
| 157 | |||||||||||
| 158 | =back | ||||||||||
| 159 | |||||||||||
| 160 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 161 | it under the same terms as Perl itself, either Perl version 5.10.1 or, | ||||||||||
| 162 | at your option, any later version of Perl 5 you may have available. | ||||||||||
| 163 | |||||||||||
| 164 | =cut | ||||||||||