Big Angry Blue Fish > Dancer-Session-ElasticSearch-1.007 > Dancer::Session::ElasticSearch

Download:
Dancer-Session-ElasticSearch-1.007.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.007   Source  

NAME ^

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

SYNOPSIS ^

This module implements a session engine storing session variables in an ElasticSearch index. It also signs IDs to thwart tampering and guessing. Requires perl version 5.10 or higher.

USAGE ^

In config.yml

  session:       "ElasticSearch"
  session_options:
    connection:
    ... settings to pass to ElasticSearch
    index: "my_index"               # defaults to "session"
    type:  "my_session"             # defaults to "session"
    signing:
        secret: "ldjaldjaklsdanm.m" # required for signing IDs
        length: 10                  # length of the salt and hash. defaults to 10
    is_lazy:    0                   # (off by default)

This session engine will not remove expired sessions on the server, but as it's ElasticSearch you can set a ttl on the documents when you create your ES index and let ES do the work for you.

METHODS ^

create()

Creates a new session. Returns the session object.

flush()

Write the session to ES. Returns the session object.

retrieve($id)

Look for a session with the given id.

Returns the session object if found, undef if not.

destroy()

Remove the current session object from ES

is_lazy

Accessor for the is_lazy session_option. Is off by default. When switched off every get/set call will read/write from ES, which can be expensive (access a variable or two and you make a get request to ES each time).

If you switch it on, you will need to call flush yourself (in an after hook, for example) to save session data to the backend.

INTERNAL METHODS ^

_es

Connect to ElasticSearch and returns a handle

init

Overload the init method in Dancer::Session::Abstract to not create an ID as we will use the ElasticSearch ID instead.

_verify($string)

Verifies a signed ID

_sign($id)

Signs an ID

_hash($id, $salt)

Creates a hash from the $id, $salt and secret key as found in the config

FORK ME ^

Fork a copy for yourself from https://github.com/babf/Dancer-Session-ElasticSearch

SEE ALSO ^

Dancer, Dancer::Session

syntax highlighting: