StandardSessionConnection
in package
implements
SessionConnectionInterface
Uses
SessionConnectionConfigTrait
The standard connection performs the read and write operations to DynamoDB.
Interfaces, Classes and Traits
- SessionConnectionInterface
- The session connection provides the underlying logic for interacting with Amazon DynamoDB and performs all of the reading and writing operations.
Table of Contents
- $batchConfig : string
- $client : DynamoDbClient
- $consistentRead : string
- $dataAttribute : string
- $dataAttributeType : string
- $hashKey : string
- $locking : bool
- $maxLockRetryMicrotime : int
- $maxLockWaitTime : int
- $minLockRetryMicrotime : int
- $sessionLifetime : int
- $sessionLifetimeAttribute : string
- $tableName : string
- __construct() : mixed
- delete() : bool
- Deletes session record from DynamoDB
- deleteExpired() : bool
- Performs garbage collection on the sessions stored in the DynamoDB
- getBatchConfig() : mixed
- getDataAttribute() : string
- getDataAttributeType() : string
- getHashKey() : string
- getMaxLockRetryMicrotime() : number
- getMaxLockWaitTime() : number
- getMinLockRetryMicrotime() : number
- getSessionLifetime() : number
- getSessionLifetimeAttribute() : string
- getTableName() : string
- initConfig() : mixed
- It initialize the Config class and it sets values in case of valid configurations.
- isConsistentRead() : bool
- isLocking() : bool
- read() : array<string|int, mixed>
- Reads session data from DynamoDB
- setBatchConfig() : mixed
- setConsistentRead() : mixed
- setDataAttribute() : mixed
- setDataAttributeType() : mixed
- setHashKey() : mixed
- setLocking() : mixed
- setMaxLockRetryMicrotime() : mixed
- setMaxLockWaitTime() : mixed
- setMinLockRetryMicrotime() : mixed
- setSessionLifetime() : mixed
- setSessionLifetimeAttribute() : mixed
- setTableName() : mixed
- write() : bool
- Writes session data to DynamoDB
- formatKey() : array<string|int, mixed>
- triggerError() : bool
Properties
$batchConfig
protected
string
$batchConfig
= []
Batch options used for garbage collection
$client
protected
DynamoDbClient
$client
The DynamoDB client
$consistentRead
protected
string
$consistentRead
= true
Whether or not to use consistent reads
$dataAttribute
protected
string
$dataAttribute
= 'data'
Name of the data attribute in table. Default: "data"
$dataAttributeType
protected
string
$dataAttributeType
= 'string'
Type of the data attribute in table. Default: "string"
$hashKey
protected
string
$hashKey
= 'id'
Name of hash key in table. Default: "id"
$locking
protected
bool
$locking
= false
Whether or not to use session locking
$maxLockRetryMicrotime
protected
int
$maxLockRetryMicrotime
= 50000
Max time (µs) to wait between lock attempts
$maxLockWaitTime
protected
int
$maxLockWaitTime
= 10
Max time (s) to wait for lock acquisition
$minLockRetryMicrotime
protected
int
$minLockRetryMicrotime
= 10000
Min time (µs) to wait between lock attempts
$sessionLifetime
protected
int
$sessionLifetime
Lifetime of inactive sessions expiration
$sessionLifetimeAttribute
protected
string
$sessionLifetimeAttribute
= 'expires'
Name of the session life time attribute in table. Default: "expires"
$tableName
protected
string
$tableName
= 'sessions'
Name of table to store the sessions
Methods
__construct()
public
__construct(DynamoDbClient $client[, array<string|int, mixed> $config = [] ]) : mixed
Parameters
- $client : DynamoDbClient
-
DynamoDB client
- $config : array<string|int, mixed> = []
-
Session handler config
Return values
mixed —delete()
Deletes session record from DynamoDB
public
delete(mixed $id) : bool
Parameters
- $id : mixed
-
Session ID
Return values
bool —deleteExpired()
Performs garbage collection on the sessions stored in the DynamoDB
public
deleteExpired() : bool
Return values
bool —getBatchConfig()
public
getBatchConfig() : mixed
Return values
mixed —getDataAttribute()
public
getDataAttribute() : string
Return values
string —getDataAttributeType()
public
getDataAttributeType() : string
Return values
string —getHashKey()
public
getHashKey() : string
Return values
string —getMaxLockRetryMicrotime()
public
getMaxLockRetryMicrotime() : number
Return values
number —getMaxLockWaitTime()
public
getMaxLockWaitTime() : number
Return values
number —getMinLockRetryMicrotime()
public
getMinLockRetryMicrotime() : number
Return values
number —getSessionLifetime()
public
getSessionLifetime() : number
Return values
number —getSessionLifetimeAttribute()
public
getSessionLifetimeAttribute() : string
Return values
string —getTableName()
public
getTableName() : string
Return values
string —initConfig()
It initialize the Config class and it sets values in case of valid configurations.
public
initConfig([array<string|int, mixed> $config = [] ]) : mixed
It transforms parameters underscore separated in camelcase "this_is_a_test" => ThisIsATest and it uses it in order to set the values.
Parameters
- $config : array<string|int, mixed> = []
Return values
mixed —isConsistentRead()
public
isConsistentRead() : bool
Return values
bool —isLocking()
public
isLocking() : bool
Return values
bool —read()
Reads session data from DynamoDB
public
read(mixed $id) : array<string|int, mixed>
Parameters
- $id : mixed
-
Session ID
Return values
array<string|int, mixed> —setBatchConfig()
public
setBatchConfig(mixed $batchConfig) : mixed
Parameters
- $batchConfig : mixed
Return values
mixed —setConsistentRead()
public
setConsistentRead(bool $consistentRead) : mixed
Parameters
- $consistentRead : bool
Return values
mixed —setDataAttribute()
public
setDataAttribute(string $dataAttribute) : mixed
Parameters
- $dataAttribute : string
Return values
mixed —setDataAttributeType()
public
setDataAttributeType(string $dataAttributeType) : mixed
Parameters
- $dataAttributeType : string
Return values
mixed —setHashKey()
public
setHashKey(string $hashKey) : mixed
Parameters
- $hashKey : string
Return values
mixed —setLocking()
public
setLocking(bool $locking) : mixed
Parameters
- $locking : bool
Return values
mixed —setMaxLockRetryMicrotime()
public
setMaxLockRetryMicrotime(number $maxLockRetryMicrotime) : mixed
Parameters
- $maxLockRetryMicrotime : number
Return values
mixed —setMaxLockWaitTime()
public
setMaxLockWaitTime(number $maxLockWaitTime) : mixed
Parameters
- $maxLockWaitTime : number
Return values
mixed —setMinLockRetryMicrotime()
public
setMinLockRetryMicrotime(number $minLockRetryMicrotime) : mixed
Parameters
- $minLockRetryMicrotime : number
Return values
mixed —setSessionLifetime()
public
setSessionLifetime(number $sessionLifetime) : mixed
Parameters
- $sessionLifetime : number
Return values
mixed —setSessionLifetimeAttribute()
public
setSessionLifetimeAttribute(string $sessionLifetimeAttribute) : mixed
Parameters
- $sessionLifetimeAttribute : string
Return values
mixed —setTableName()
public
setTableName(string $tableName) : mixed
Parameters
- $tableName : string
Return values
mixed —write()
Writes session data to DynamoDB
public
write(mixed $id, mixed $data, mixed $isChanged) : bool
Parameters
- $id : mixed
-
Session ID
- $data : mixed
-
Serialized session data
- $isChanged : mixed
-
Whether or not the data has changed
Return values
bool —formatKey()
protected
formatKey(string $key) : array<string|int, mixed>
Parameters
- $key : string
Return values
array<string|int, mixed> —triggerError()
protected
triggerError(string $error) : bool
Parameters
- $error : string