PHP Класс yii\redis\Session
Redis Session requires redis version 2.6.12 or higher to work properly.
It needs to be configured with a redis
Connection that is also configured as an application component.
By default it will use the
redis application component.
To use redis Session as the session application component, configure the application as follows,
~~~
[
'components' => [
'session' => [
'class' => 'yii\redis\Session',
'redis' => [
'hostname' => 'localhost',
'port' => 6379,
'database' => 0,
]
],
],
]
~~~
Or if you have configured the redis
Connection as an application component, the following is sufficient:
~~~
[
'components' => [
'session' => [
'class' => 'yii\redis\Session',
'redis' => 'redis' // id of the connection application component
],
],
]
~~~
Показать файл
Открыть проект
Открытые свойства
Свойство |
Тип |
Описание |
|
$keyPrefix |
|
a string prefixed to every cache key so that it is unique. If not set,
it will use a prefix generated from [[Application::id]]. You may set this property to be an empty string
if you don't want to use key prefix. It is recommended that you explicitly set this property to some
static value if the cached data needs to be shared among multiple applications. |
|
$redis |
|
the Redis Connection object or the application component ID of the Redis Connection.
This can also be an array that is used to create a redis Connection instance in case you do not want do configure
redis connection as an application component.
After the Session object is created, if you want to change this property, you should only assign it
with a Redis Connection object. |
|
Открытые методы
Защищенные методы
Описание методов
calculateKey()
защищенный Метод
Generates a unique key used for storing session data in cache.
destroySession()
публичный Метод
Do not call this method directly.
getUseCustomStorage()
публичный Метод
This method overrides the parent implementation and always returns true.
This method will initialize the [[redis]] property to make sure it refers to a valid redis connection.
readSession()
публичный Метод
Do not call this method directly.
writeSession()
публичный Метод
Do not call this method directly.
Описание свойств
$keyPrefix публичное свойство
a string prefixed to every cache key so that it is unique. If not set,
it will use a prefix generated from [[Application::id]]. You may set this property to be an empty string
if you don't want to use key prefix. It is recommended that you explicitly set this property to some
static value if the cached data needs to be shared among multiple applications.
$redis публичное свойство
the Redis
Connection object or the application component ID of the Redis
Connection.
This can also be an array that is used to create a redis
Connection instance in case you do not want do configure
redis connection as an application component.
After the Session object is created, if you want to change this property, you should only assign it
with a Redis
Connection object.