PHP Class yii\web\CacheSession
The cache being used can be any cache application component.
The ID of the cache application component is specified via [[cache]], 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 database as storage medium,
DbSession is a better choice.
The following example shows how you can configure the application to use CacheSession:
Add the following to your application config under
components:
php
'session' => [
'class' => 'yii\web\CacheSession',
'cache' => 'mycache',
]
ファイルを表示
Open project: yiisoft/yii2
Class Usage Examples
Public Properties
Property |
Type |
Description |
|
$cache |
|
the cache object or the application component ID of the cache object.
The session data will be stored using this cache object.
After the CacheSession object is created, if you want to change this property,
you should only assign it with a cache object.
Starting from version 2.0.2, this can also be a configuration array for creating the object. |
|
Public Methods
Protected Methods
Method |
Description |
|
calculateKey ( string $id ) : mixed |
Generates a unique key used for storing session data in cache. |
|
Method Details
calculateKey()
protected method
Generates a unique key used for storing session data in cache.
destroySession()
public method
Do not call this method directly.
getUseCustomStorage()
public method
This method overrides the parent implementation and always returns true.
Initializes the application component.
readSession()
public method
Do not call this method directly.
writeSession()
public method
Do not call this method directly.
Property Details
$cache public_oe property
the cache object or the application component ID of the cache object.
The session data will be stored using this cache object.
After the CacheSession object is created, if you want to change this property,
you should only assign it with a cache object.
Starting from version 2.0.2, this can also be a configuration array for creating the object.