## Class TCacheHttpSession

Description

TCacheHttpSession class

TCacheHttpSession provides access for storing session data using a cache module (e.g. TMemCache, TDbCache). To specify the cache module for data storage, set the CacheModuleID property which should refer to a valid cache module configured in the application configuration.

The following example shows how we configure TCacheHttpSession:

      <modules>
        <module id="cache" class="System.Caching.TMemCache" Host="localhost" Port="11211" />
        <module id="session" class="System.Web.TCacheHttpSession"
             CacheModuleID="cache" SessionName="SSID"
             CookieMode="Allow" AutoStart="true" GCProbability="1"
             UseTransparentSessionID="true" TimeOut="3600" />
      </modules>

Beware, by definition cache storage are volatile, which means the data stored on them may be swapped out and get lost. This may not be the case for certain cache storage, such as database. So make sure you manage your cache properly to avoid loss of session data.

- since: 3.1.1
- version: $Id: TCacheHttpSession.php 2228 2007-09-17 18:18:17Z xue $
- author: Carl G. Mathisen <carlgmathisen@gmail.com>
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/TCacheHttpSession.php (line 43)

    TComponent
       |
       --TApplicationComponent
          |
          --THttpSession
             |
             --TCacheHttpSession

Method Summary
string calculateKey (string $id)
ICache getCache ()
string getCacheModuleID ()
string getKeyPrefix ()
void init (TXmlElement $config)
void setCacheModuleID (string $value)
void setKeyPrefix (string $value)
boolean _destroy (string $id)
string _read (string $id)
boolean _write (string $id, string $data)
Methods
calculateKey (line 145)

- return: a safe cache key associated with the session variable name
- access: protected

string calculateKey (string $id)

- string $id: session variable name

getCache (line 88)

- return: the cache module being used for data storage
- access: public

ICache getCache ()
getCacheModuleID (line 72)

- return: the ID of the cache module.
- access: public

string getCacheModuleID ()
getKeyPrefix (line 128)

- return: prefix of session variable name to avoid conflict with other cache data. Defaults to 'session'.
- access: public

string getKeyPrefix ()
init (line 55)

Initializes the module.

This method is required by IModule. It reads the CacheModule property.

- access: public

void init (TXmlElement $config)

- TXmlElement $config: module configuration

Redefinition of:

THttpSession::init()
  Initializes the module.

setCacheModuleID (line 80)

- access: public

void setCacheModuleID (string $value)

- string $value: the ID of the cache module.

setKeyPrefix (line 136)

- access: public

void setKeyPrefix (string $value)

- string $value: prefix of session variable name to avoid conflict with other cache data

_destroy (line 120)

Session destroy handler.

This method should be overriden if UseCustomStorage is set true.

- return: whether session is destroyed successfully
- access: public

boolean _destroy (string $id)

- string $id: session ID

Redefinition of:

THttpSession::_destroy()
  Session destroy handler.

_read (line 98)

Session read handler.

- return: the session data
- access: public

string _read (string $id)

- string $id: session ID

Redefinition of:

THttpSession::_read()
  Session read handler.

_write (line 109)

Session write handler.

- return: whether session write is successful
- access: public

boolean _write (string $id, string $data)

- string $id: session ID
- string $data: session data

Redefinition of:

THttpSession::_write()
  Session write handler.

#### Inherited Methods

Inherited From THttpSession

> THttpSession::add()
> THttpSession::clear()
> THttpSession::close()
> THttpSession::contains()
> THttpSession::count()
> THttpSession::destroy()
> THttpSession::getAutoStart()
> THttpSession::getCookie()
> THttpSession::getCookieMode()
> THttpSession::getCount()
> THttpSession::getGCProbability()
> THttpSession::getID()
> THttpSession::getIsStarted()
> THttpSession::getIterator()
> THttpSession::getKeys()
> THttpSession::getSavePath()
> THttpSession::getSessionID()
> THttpSession::getSessionName()
> THttpSession::getTimeout()
> THttpSession::getUseCustomStorage()
> THttpSession::getUseTransparentSessionID()
> THttpSession::init()
> THttpSession::itemAt()
> THttpSession::offsetExists()
> THttpSession::offsetGet()
> THttpSession::offsetSet()
> THttpSession::offsetUnset()
> THttpSession::open()
> THttpSession::remove()
> THttpSession::setAutoStart()
> THttpSession::setCookieMode()
> THttpSession::setGCProbability()
> THttpSession::setID()
> THttpSession::setSavePath()
> THttpSession::setSessionID()
> THttpSession::setSessionName()
> THttpSession::setTimeout()
> THttpSession::setUseCustomStorage()
> THttpSession::setUseTransparentSessionID()
> THttpSession::toArray()
> THttpSession::_close()
> THttpSession::_destroy()
> THttpSession::_gc()
> THttpSession::_open()
> THttpSession::_read()
> THttpSession::_write()

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

Inherited From TComponent

> TComponent::addParsedObject()
> TComponent::attachEventHandler()
> TComponent::canGetProperty()
> TComponent::canSetProperty()
> TComponent::createdOnTemplate()
> TComponent::detachEventHandler()
> TComponent::evaluateExpression()
> TComponent::evaluateStatements()
> TComponent::getEventHandlers()
> TComponent::getSubProperty()
> TComponent::hasEvent()
> TComponent::hasEventHandler()
> TComponent::hasProperty()
> TComponent::raiseEvent()
> TComponent::setSubProperty()
> TComponent::__get()
> TComponent::__set()

Documentation generated on Mon, 21 Apr 2008 11:32:06 -0400 by phpDocumentor 1.3.0RC4