Perltidy + pod tests for all session plugins
[catagits/Catalyst-Plugin-Session.git] / lib / Catalyst / Plugin / Session / Store.pm
CommitLineData
9e447f9d 1#!/usr/bin/perl
2
3package Catalyst::Plugin::Session::Store;
4
5use strict;
6use warnings;
7
9e447f9d 8__PACKAGE__;
9
10__END__
11
12=pod
13
14=head1 NAME
15
16Catalyst::Plugin::Session::Store - Base class for session storage
17drivers.
18
19=head1 SYNOPSIS
20
45c0711b 21 package Catalyst::Plugin::Session::Store::MyBackend;
22 use base qw/Catalyst::Plugin::Session::Store/;
9e447f9d 23
24=head1 DESCRIPTION
25
c80e9f04 26This class doesn't actually provide any functionality, but when the
27C<Catalyst::Plugin::Session> module sets up it will check to see that
28C<< YourApp->isa("Catalyst::Plugin::Session::Store") >>.
29
30When you write a session storage plugin you should subclass this module this
31reason only.
32
33=head1 WRITING STORE PLUGINS
34
35All session storage plugins need to adhere to the following interface
36specification to work correctly:
37
38=head2 Required Methods
39
40=over 4
41
42=item get_session_data $sid
43
44Retrieve a session from storage, whose ID is the first parameter.
45
46Should return a hash reference.
47
48=item store_session_data $sid, $hashref
49
50Store a session whose ID is the first parameter and data is the second
51parameter in storage.
52
53The second parameter is an hash reference, that should normally be serialized
54(and later deserialized by C<get_session_data>).
55
56=item delete_session_data $sid
57
58Delete the session whose ID is the first parameter.
59
60=item delete_expired_sessions
61
62This method is not called by any code at present, but may be called in the
63future, as part of a catalyst specific maintenance script.
64
65If you are wrapping around a backend which manages it's own auto expiry you can
66just give this method an empty body.
67
68=back
69
70=head2 Error handling
71
72All errors should be thrown using L<Catalyst::Exception>. Return values are not
73checked at all, and are assumed to be OK.
74
75=head2 Auto-Expirey on the Backend
76
77Storage plugins are encouraged to use C<< $c->config->{session}{expires} >> and
78the C<__expires> key in the session data hash reference to auto expire data on
79the backend side.
80
81If the backend chooses not to do so, L<Catalyst::Plugin::Session> will detect
82expired sessions as they are retrieved and delete them if necessary.
83
84Note that session storages that use this approach may leak disk space, since
85nothing will actively delete expired session. The C<delete_expired_sessions>
86method is there so that regularly scheduled maintenance scripts can give your
87backend the opportunity to clean up.
88
9e447f9d 89=cut
90
91