Richard Simões
and 1 contributors

NAME

Dancer::Session::CHI - CHI-based session engine for Dancer

SYNOPSIS

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

DESCRIPTION

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.

CONFIGURATION

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.

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.

METHODS

CLASS

create()

Creates a new session object and returns it.

retrieve($id)

Returns the session object containing an ID of $id.

OBJECT

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.

CAVEATS

  • 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.

BUGS

This is an initial TRIAL release, so bugs may be lurking. Please report any issues to this module's GitHub issues page.

AUTHOR

Richard Simões <rsimoes at CPAN dot org>

COPYRIGHT & LICENSE

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.