| 1 | package Dancer::Session::Simple; | ||
| 2 | 91 | our $AUTHORITY = 'cpan:SUKRIA'; | |
| 3 | #ABSTRACT: in-memory session backend for Dancer | ||
| 4 | 91 | $Dancer::Session::Simple::VERSION = '1.3520'; | |
| 5 | 91 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 91 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 91 | ▶ | use base 'Dancer::Session::Abstract'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 91 | my %sessions; | |
| 10 | |||
| 11 | # create a new session and return the newborn object | ||
| 12 | # representing that session | ||
| 13 | sub create { | ||
| 14 | 35 | ▶ | my ($class) = @_; |
|
Subroutine
create: called CC=1 SCAR=0.0
Pod
documented
| |||
| 15 | |||
| 16 | 35 | my $self = Dancer::Session::Simple->new; | |
| 17 | 35 | $self->flush; | |
| 18 | 35 | return $self; | |
| 19 | } | ||
| 20 | |||
| 21 | # Return the session object corresponding to the given id | ||
| 22 | sub retrieve { | ||
| 23 | 67 | ▶ | my ($class, $id) = @_; |
|
Subroutine
retrieve: called CC=1 SCAR=0.0
Pod
documented
| |||
| 24 | |||
| 25 | 67 | return $sessions{$id}; | |
| 26 | } | ||
| 27 | |||
| 28 | |||
| 29 | sub destroy { | ||
| 30 | 1 | ▶ | my ($self) = @_; |
|
Subroutine
destroy: called CC=1 SCAR=0.0
Pod
documented
| |||
| 31 | 1 | undef $sessions{$self->id}; | |
| 32 | } | ||
| 33 | |||
| 34 | sub flush { | ||
| 35 | 43 | ▶ | my $self = shift; |
|
Subroutine
flush: called CC=1 SCAR=0.0
Pod
documented
| |||
| 36 | 43 | $sessions{$self->id} = $self; | |
| 37 | 43 | return $self; | |
| 38 | } | ||
| 39 | |||
| 40 | 91 | 1; | |
| 41 | |||
| 42 | __END__ | ||