| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PAGI::Middleware::Session::Store; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
203132
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
121
|
|
|
4
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
665
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
PAGI::Middleware::Session::Store - Base class for async session storage |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package My::Store; |
|
13
|
|
|
|
|
|
|
use parent 'PAGI::Middleware::Session::Store'; |
|
14
|
|
|
|
|
|
|
use Future; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get { |
|
17
|
|
|
|
|
|
|
my ($self, $id) = @_; |
|
18
|
|
|
|
|
|
|
# Return Future resolving to hashref or undef |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub set { |
|
22
|
|
|
|
|
|
|
my ($self, $id, $data) = @_; |
|
23
|
|
|
|
|
|
|
# Return Future resolving to 1 |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub delete { |
|
27
|
|
|
|
|
|
|
my ($self, $id) = @_; |
|
28
|
|
|
|
|
|
|
# Return Future resolving to 1 |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
PAGI::Middleware::Session::Store defines the async interface for session |
|
34
|
|
|
|
|
|
|
storage backends. All methods return L objects so that storage |
|
35
|
|
|
|
|
|
|
operations can be asynchronous (e.g. Redis, database). |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Subclasses must implement C, C, and C. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 new |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $store = PAGI::Middleware::Session::Store->new(%options); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Create a new store instance. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new { |
|
50
|
21
|
|
|
21
|
1
|
224887
|
my ($class, %options) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
21
|
|
|
|
|
57
|
return bless { %options }, $class; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 get |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $future = $store->get($id); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Retrieve session data for the given ID. Returns a Future that resolves |
|
60
|
|
|
|
|
|
|
to a hashref of session data, or undef if no session exists for that ID. |
|
61
|
|
|
|
|
|
|
Subclasses must implement this. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get { |
|
66
|
1
|
|
|
1
|
1
|
20
|
my ($self, $id) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
9
|
die ref($self) . " must implement get()"; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 set |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $future = $store->set($id, $data); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Store session data for the given ID. Returns a Future that resolves to 1 |
|
76
|
|
|
|
|
|
|
on success. Subclasses must implement this. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub set { |
|
81
|
1
|
|
|
1
|
1
|
18
|
my ($self, $id, $data) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
9
|
die ref($self) . " must implement set()"; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 delete |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $future = $store->delete($id); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Remove session data for the given ID. Returns a Future that resolves to 1 |
|
91
|
|
|
|
|
|
|
on success. Subclasses must implement this. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub delete { |
|
96
|
1
|
|
|
1
|
1
|
15
|
my ($self, $id) = @_; |
|
97
|
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
10
|
die ref($self) . " must implement delete()"; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |