| 1 | ############################################################################# | ||
| 2 | # | ||
| 3 | # Apache::Session::Browseable::SQLite | ||
| 4 | # Apache persistent user sessions in a SQLite database | ||
| 5 | # Copyright(c) 2013-2017 Xavier Guimard <x.guimard@free.fr> | ||
| 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 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | 2 | ▶ | use Apache::Session; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 2 | ▶ | use Apache::Session::Lock::Null; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 2 | ▶ | use Apache::Session::Browseable::Store::SQLite; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 2 | ▶ | use Apache::Session::Generate::SHA256; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 2 | ▶ | use Apache::Session::Serialize::JSON; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | 2 | ▶ | use Apache::Session::Browseable::DBI; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | |||
| 23 | 2 | our $VERSION = '1.2.2'; | |
| 24 | 2 | our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); | |
| 25 | |||
| 26 | 177 | ▶ | sub populate { |
|
Subroutine
populate: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 27 | 177 | my $self = shift; | |
| 28 | |||
| 29 | $self->{object_store} = | ||
| 30 | 177 | new Apache::Session::Browseable::Store::SQLite $self; | |
| 31 | 177 | $self->{lock_manager} = new Apache::Session::Lock::Null $self; | |
| 32 | 177 | $self->{generate} = \&Apache::Session::Generate::SHA256::generate; | |
| 33 | 177 | $self->{validate} = \&Apache::Session::Generate::SHA256::validate; | |
| 34 | 177 | $self->{serialize} = \&Apache::Session::Serialize::JSON::serialize; | |
| 35 | 177 | $self->{unserialize} = \&Apache::Session::Serialize::JSON::unserialize; | |
| 36 | |||
| 37 | 177 | return $self; | |
| 38 | } | ||
| 39 | |||
| 40 | 2 | 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<Apache::Session::Browseable> 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 <x.guimard@free.fr> using | ||
| 88 | Apache::Session::Postgres from Jeffrey William Baker as example. | ||
| 89 | |||
| 90 | =head1 SEE ALSO | ||
| 91 | |||
| 92 | L<Apache::Session::Browseable> | ||