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 ], ], ] ~~~
부터: 2.0
저자: Carsten Brandt ([email protected])
상속: extends yii\web\Session
파일 보기 프로젝트 열기: yiisoft/yii2-redis

공개 프로퍼티들

프로퍼티 타입 설명
$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.

공개 메소드들

메소드 설명
destroySession ( string $id ) : boolean Session destroy handler.
getUseCustomStorage ( ) : boolean Returns a value indicating whether to use custom session storage.
init ( ) Initializes the redis Session component.
readSession ( string $id ) : string Session read handler.
writeSession ( string $id, string $data ) : boolean Session write handler.

보호된 메소드들

메소드 설명
calculateKey ( string $id ) : string Generates a unique key used for storing session data in cache.

메소드 상세

calculateKey() 보호된 메소드

Generates a unique key used for storing session data in cache.
protected calculateKey ( string $id ) : string
$id string session variable name
리턴 string a safe cache key associated with the session variable name

destroySession() 공개 메소드

Do not call this method directly.
public destroySession ( string $id ) : boolean
$id string session ID
리턴 boolean whether session is destroyed successfully

getUseCustomStorage() 공개 메소드

This method overrides the parent implementation and always returns true.
public getUseCustomStorage ( ) : boolean
리턴 boolean whether to use custom storage.

init() 공개 메소드

This method will initialize the [[redis]] property to make sure it refers to a valid redis connection.
public init ( )

readSession() 공개 메소드

Do not call this method directly.
public readSession ( string $id ) : string
$id string session ID
리턴 string the session data

writeSession() 공개 메소드

Do not call this method directly.
public writeSession ( string $id, string $data ) : boolean
$id string session ID
$data string session data
리턴 boolean whether session write is successful

프로퍼티 상세

$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.
public $keyPrefix

$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.
public $redis