File Coverage

blib/lib/Apache/Session/Browseable/SQLite.pm
Criterion Covered Total %
statement 29 29 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 37 38 97.3


line stmt bran cond sub pod time code
1             #############################################################################
2             #
3             # Apache::Session::Browseable::SQLite
4             # Apache persistent user sessions in a SQLite database
5             # Copyright(c) 2013-2017 Xavier Guimard
6             # Inspired by Apache::Session::Postgres
7             # (copyright(c) 1998, 1999, 2000 Jeffrey William Baker (jwbaker@acm.org))
8             # Distribute under the Perl License
9             #
10             ############################################################################
11              
12             package Apache::Session::Browseable::SQLite;
13              
14 2     2   140788 use strict;
  2         10  
  2         177  
15              
16 2     2   1876 use Apache::Session;
  2         6525  
  2         108  
17 2     2   1282 use Apache::Session::Lock::Null;
  2         515  
  2         80  
18 2     2   1358 use Apache::Session::Browseable::Store::SQLite;
  2         6  
  2         103  
19 2     2   980 use Apache::Session::Generate::SHA256;
  2         6  
  2         92  
20 2     2   951 use Apache::Session::Serialize::JSON;
  2         11  
  2         64  
21 2     2   927 use Apache::Session::Browseable::DBI;
  2         6  
  2         302  
22              
23             our $VERSION = '1.2.2';
24             our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session);
25              
26             sub populate {
27 177     177 0 2397 my $self = shift;
28              
29             $self->{object_store} =
30 177         580 new Apache::Session::Browseable::Store::SQLite $self;
31 177         1413 $self->{lock_manager} = new Apache::Session::Lock::Null $self;
32 177         995 $self->{generate} = \&Apache::Session::Generate::SHA256::generate;
33 177         365 $self->{validate} = \&Apache::Session::Generate::SHA256::validate;
34 177         314 $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize;
35 177         322 $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize;
36              
37 177         1023 return $self;
38             }
39              
40             1;
41              
42             =pod
43              
44             =head1 NAME
45              
46             Apache::Session::Browseable::SQLite - An implementation of Apache::Session
47              
48             =head1 SYNOPSIS
49              
50             use Apache::Session::Browseable::SQLite;
51              
52             #if you want Apache::Session to open new DB handles:
53              
54             tie %hash, 'Apache::Session::Browseable::SQLite', $id, {
55             DataSource => 'dbi:Pg:dbname=sessions',
56             UserName => $db_user,
57             Password => $db_pass,
58             Commit => 1
59             };
60              
61             #or, if your handles are already opened:
62              
63             tie %hash, 'Apache::Session::Browseable::SQLite', $id, {
64             Handle => $dbh,
65             Commit => 1
66             };
67              
68             L function are also available
69              
70             =head1 DESCRIPTION
71              
72             This module is an implementation of Apache::Session. It uses the SQLite
73             backing store and no locking. See the example, and the documentation for
74             Apache::Session::Browseable::Store::SQLite for more details.
75              
76             =head1 USAGE
77              
78             The special Apache::Session argument for this module is Commit. You MUST
79             provide the Commit argument, which instructs this module to either commit
80             the transaction when it is finished, or to simply do nothing. This feature
81             is provided so that this module will not have adverse interactions with your
82             local transaction policy, nor your local database handle caching policy. The
83             argument is mandatory in order to make you think about this problem.
84              
85             =head1 AUTHOR
86              
87             This module was written by Xavier Guimard using
88             Apache::Session::Postgres from Jeffrey William Baker as example.
89              
90             =head1 SEE ALSO
91              
92             L