Dancer::Session::CHI - CHI-based session engine for Dancer
In a Dancer application:
set session => "CHI"; set session_expires => "1 hour"; set session_CHI => { use_plugin => 1 }; set plugins => { "Cache::CHI" => { driver => 'Memory', global => 1 } };
In a config.yml:
session: CHI session_expires: 1 hour session_CHI: use_plugin: 1 plugins: Cache::CHI: driver: Memory global: 1
This module leverages CHI to provide session management for Dancer applications. Just as Dancer::Session::KiokuDB opens up KiokuDB's full range of KiokuDB::Backend::* modules to be used in Dancer session management, Dancer::Session::CHI makes available the complete CHI::Driver::* collection.
KiokuDB::Backend
CHI::Driver
Under its session_CHI key, Dancer::Session::CHI accepts a use_plugin option that defaults to 0. If set to 1, Dancer::Plugin::Cache::CHI will be used directly for session management, with no changes made to the plugin's configuration.
session_CHI
use_plugin
0
1
If use_plugin is left false, all other options are passed through to construct a new CHI object, even if Dancer::Plugin::Cache::CHI is also in use. This new object needn't use the same CHI::Driver as the plugin.
create()
Creates a new session object and returns it.
retrieve($id)
Returns the session object containing an ID of $id.
flush()
Writes all session data to the CHI storage backend.
destroy()
Ends a Dancer session and wipes the session's data from the CHI storage backend.
purge()
Direct access to CHI's purge() method, clearing the data of all expired sessions from the CHI storage backend.
Some CHI::Driver parameters are sufficiently complex to not be placeable in a config.yml. Session and/or plugin configuration may instead be needed to be done in application code.
When using CHI::Driver::DBI, thread/fork safety can be ensured by passing it a DBIx::Connector object or database handle returned by Dancer::Plugin::Database's database() subroutine.
database()
This is an initial TRIAL release, so bugs may be lurking. Please report any issues to this module's GitHub issues page.
Richard Simões <rsimoes at CPAN dot org>
Copyright © 2013 Richard Simões. This module is released under the terms of the MIT License and may be modified and/or redistributed under the same or any compatible license.
To install Dancer::Session::CHI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Session::CHI
CPAN shell
perl -MCPAN -e shell install Dancer::Session::CHI
For more information on module installation, please visit the detailed CPAN module installation guide.