HTTP::Daemon::Threaded::SessionCache

SUMMARY: CONSTR | METHOD | DETAIL: CONSTR | METHOD

## Class HTTP::Daemon::Threaded::SessionCache

Abstract base class for SessionCache classes. Provides an interface definition for caching session context in a threads::shared container. Provides a default implementation to create non-persistent sessions. Also acts as a factory for Session objects.

Note: Applications needing to provide their own session class implementations should subclass this class instead, and provide an instance of the subclass as the HTTP::Daemon::Threaded constructor's SessionCache parameter. Such subclass instances may then manufacture session objects using their own Session subclass.

Copyright© 2006, Dean Arnold, Presicient Corp., USA
All rights reserved.

Licensed under the Academic Free License version 2.1, as specified in the License.txt file included in this software package, or at OpenSource.org.

Author:
  D. Arnold
Version:
  0.90
Since:
  2006-08-21

Unless otherwise noted, `$self` is the object instance variable.

Constructor Summary
`new()` Creates threads::shared object to contain any Session object that will be created

Method Summary
`addSession($session)` Add a new session to the cache
`createSession($id, $timeout, $dough, $expires)` Create a new session and store in the cache
`getSession($request)` Get a session from the cache
`openSession($cookie)` Recover an existing session from persistent storage
`removeSession($id)` Remove a session from the cache

Constructor Details

### new

    new()

  Creates threads::shared object to contain any Session object that will be created.

  Subclasses should extend this to open any session storage, and possible pre-cache session contexts.

  Returns:
    HTTP::Daemon::Threaded::SessionCache object

Method Details

### addSession

    addSession($session)

  Add a new session to the cache.

  Parameters:
    `$session` - HTTP::Daemon::Threaded::Session object
  Returns:
    the HTTP::Daemon::Threaded::Session object

### createSession

    createSession($id, $timeout, $dough, $expires)

  Create a new session and store in the cache.

  Parameters:
    `$id` - (optional) unique ID of session to retrieve; default is whatever the session object class generates
    `$timeout` - (optional) max inactivity timeout; default is class specific
    `$dough` - (optional) any information to be included in the session's cookie; the $id will be prepended to this information
    `$expires` - (optional) RFC1123 formatted cookie expiration date string, or 'Never'; default is single session (nonpersistent)
  Returns:
    undef if a session with the same ID already exists, or if the session object cannot be created; otherwise, the created HTTP::Daemon::Threaded::Session object

### getSession

    getSession($request)

  Get a session from the cache.

  Parameters:
    `$request` - HTTP::Request object for which a session is to be located
  Returns:
    the HTTP::Daemon::Threaded::Session object if it exists; undef otherwise

### openSession

    openSession($cookie)

  Recover an existing session from persistent storage.

  Parameters:
    `$cookie` - (required) HTTP Cookie header containing unique ID of session to retrieve
  Returns:
    undef if the session object cannot be recovered; otherwise, the HTTP::Daemon::Threaded::Session object

### removeSession

    removeSession($id)

  Remove a session from the cache.

  Parameters:
    `$id` - unique ID of session to be removed
  Returns:
    the HTTP::Daemon::Threaded::SessionCache object

Generated by psichedoc on Mon Aug 28 09:45:39 2006