Class CCacheHttpSession
CCacheHttpSession implements a session component using cache as storage
medium.
The cache being used can be any cache application component implementing
ICache
interface. The ID of the cache application component is specified
via CCacheHttpSession::$cacheID
, which defaults to 'cache'.
Beware, by definition cache storage are volatile, which means the data stored
on them may be swapped out and get lost. Therefore, you must make sure the cache
used by this component is NOT volatile. If you want to use CDbCache
as
storage medium, use CDbHttpSession
is a better choice.
-
CComponent
-
CApplicationComponent
implements
IApplicationComponent
-
CHttpSession
implements
IteratorAggregate,
ArrayAccess,
Countable
-
CCacheHttpSession
Methods summary
public
|
#
init( )
Initializes the application component. This method overrides the parent
implementation by checking if cache is available.
Initializes the application component. This method overrides the parent
implementation by checking if cache is available.
Overrides
|
public
boolean
|
#
getUseCustomStorage( )
Returns a value indicating whether to use custom session storage. This method
overrides the parent implementation and always returns true.
Returns a value indicating whether to use custom session storage. This method
overrides the parent implementation and always returns true.
Returns
boolean whether to use custom storage.
Overrides
|
public
string
|
#
readSession( string $id )
Session read handler. Do not call this method directly.
Session read handler. Do not call this method directly.
Parameters
Returns
string the session data
Overrides
|
public
boolean
|
#
writeSession( string $id, string $data )
Session write handler. Do not call this method directly.
Session write handler. Do not call this method directly.
Parameters
- $id
string $id session ID
- $data
string $data session data
Returns
boolean whether session write is successful
Overrides
|
public
boolean
|
#
destroySession( string $id )
Session destroy handler. Do not call this method directly.
Session destroy handler. Do not call this method directly.
Parameters
Returns
boolean whether session is destroyed successfully
Overrides
|
protected
string
|
#
calculateKey( string $id )
Generates a unique key used for storing session data in cache.
Generates a unique key used for storing session data in cache.
Parameters
- $id
string $id session variable name
Returns
string a safe cache key associated with the session variable name
|
Methods inherited from CHttpSession
add(),
clear(),
close(),
closeSession(),
contains(),
count(),
destroy(),
gcSession(),
get(),
getCookieMode(),
getCookieParams(),
getCount(),
getGCProbability(),
getIsStarted(),
getIterator(),
getKeys(),
getSavePath(),
getSessionID(),
getSessionName(),
getTimeout(),
getUseTransparentSessionID(),
itemAt(),
offsetExists(),
offsetGet(),
offsetSet(),
offsetUnset(),
open(),
openSession(),
regenerateID(),
remove(),
setCookieMode(),
setCookieParams(),
setGCProbability(),
setSavePath(),
setSessionID(),
setSessionName(),
setTimeout(),
setUseTransparentSessionID(),
toArray()
|
Methods inherited from CComponent
__call(),
__get(),
__isset(),
__set(),
__unset(),
asa(),
attachBehavior(),
attachBehaviors(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
detachBehavior(),
detachBehaviors(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
getEventHandlers(),
hasEvent(),
hasEventHandler(),
hasProperty(),
raiseEvent()
|
Constants summary
string |
CACHE_KEY_PREFIX
|
'Yii.CCacheHttpSession.' |
#
Prefix to the keys for storing cached data
Prefix to the keys for storing cached data
|
Properties summary
public
string
|
$cacheID
|
'cache' |
#
the ID of the cache application component. Defaults to 'cache' (the primary
cache application component.)
the ID of the cache application component. Defaults to 'cache' (the primary
cache application component.)
|
Magic properties summary
public
boolean
|
$useCustomStorage
|
#
Whether to use custom storage.
Whether to use custom storage.
|
Magic properties inherited from CHttpSession
$cookieMode,
$cookieParams,
$count,
$gCProbability,
$isStarted,
$iterator,
$keys,
$savePath,
$sessionID,
$sessionName,
$timeout,
$useTransparentSessionID
|