blib/lib/PAGI/Middleware/Session/Store.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 4 / 4 totaltotal 100% 26 / 26 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
new
1.0
CRAP 1.0
« blib/lib/PAGI/Middleware/Session/State.pm ↑ Summary blib/lib/PAGI/Middleware/Session/Store/Memory.pm »
1 package PAGI::Middleware::Session::Store;
2 3 $PAGI::Middleware::Session::Store::VERSION = '0.002002';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =encoding UTF-8
7  
8 =head1 NAME
9  
10 PAGI::Middleware::Session::Store - Base class for async session storage
11  
12 =head1 SYNOPSIS
13  
14 package My::Store;
15 use parent 'PAGI::Middleware::Session::Store';
16 use Future;
17  
18 sub get {
19 my ($self, $id) = @_;
20 # Return Future resolving to hashref or undef
21 }
22  
23 sub set {
24 my ($self, $id, $data) = @_;
25 # Return Future resolving to the transport value
26 }
27  
28 sub delete {
29 my ($self, $id) = @_;
30 # Return Future resolving to 1
31 }
32  
33 =head1 DESCRIPTION
34  
35 PAGI::Middleware::Session::Store defines the async interface for session
36 storage backends. All methods return L<Future> objects so that storage
37 operations can be asynchronous (e.g. Redis, database).
38  
39 Subclasses must implement C<get>, C<set>, and C<delete>.
40  
41 =head1 METHODS
42  
43 =head2 new
44  
45 my $store = PAGI::Middleware::Session::Store->new(%options);
46  
47 Create a new store instance.
48  
49 =cut
50  
51 32 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
52 32 my ($class, %options) = @_;
53  
54 32 return bless { %options }, $class;
55 }
56  
57 =head2 get
58  
59 my $future = $store->get($id);
60  
61 Retrieve session data for the given ID. Returns a Future that resolves
62 to a hashref of session data, or undef if no session exists for that ID.
63 Subclasses must implement this.
64  
65 =cut
66  
67 1 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
68 1 my ($self, $id) = @_;
69  
70 1 die ref($self) . " must implement get()";
71 }
72  
73 =head2 set
74  
75 my $future = $store->set($id, $data);
76  
77 Store session data for the given ID. Returns a Future that resolves to
78 the B<transport value> — the opaque token the session middleware hands to
79 the State handler to send to the client. For server-side stores this is the
80 session ID (unchanged from the C<$id> argument); for cookie stores it is the
81 encoded session blob. Subclasses must implement this.
82  
83 =cut
84  
85 1 ▶sub set {
Subroutine set: called CC=1 SCAR=0.0
Pod documented
86 1 my ($self, $id, $data) = @_;
87  
88 1 die ref($self) . " must implement set()";
89 }
90  
91 =head2 delete
92  
93 my $future = $store->delete($id);
94  
95 Remove session data for the given ID. Returns a Future that resolves to 1
96 on success. Subclasses must implement this.
97  
98 =cut
99  
100 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
101 1 my ($self, $id) = @_;
102  
103 1 die ref($self) . " must implement delete()";
104 }
105  
106 3 1;
107  
108 __END__
« blib/lib/PAGI/Middleware/Session/State.pm ↑ Summary blib/lib/PAGI/Middleware/Session/Store/Memory.pm »