class Database implements StoreInterface

Database store.

Properties

protected Connection $connection Database connection.
protected string $table Database table.
protected array|bool $classWhitelist Class whitelist.

Methods

__construct(Connection $connection, string $table, array|bool $classWhitelist = false)

Constructor.

table()

Returns a query builder instance.

write(string $sessionId, array $sessionData, int $dataTTL)

Writes session data.

array
read(string $sessionId)

Reads and returns session data.

delete(string $sessionId)

Destroys the session data assiciated with the provided id.

gc(int $dataTTL)

Garbage collector that deletes expired session data.

Details

at line 50
__construct(Connection $connection, string $table, array|bool $classWhitelist = false)

Constructor.

Parameters

Connection $connection Database connection
string $table Database table
array|bool $classWhitelist Class whitelist

at line 64
protected Query table()

Returns a query builder instance.

Return Value

Query

at line 72
write(string $sessionId, array $sessionData, int $dataTTL)

Writes session data.

Parameters

string $sessionId Session id
array $sessionData Session data
int $dataTTL TTL in seconds

at line 93
array read(string $sessionId)

Reads and returns session data.

Parameters

string $sessionId Session id

Return Value

array

at line 103
delete(string $sessionId)

Destroys the session data assiciated with the provided id.

Parameters

string $sessionId Session id

at line 111
gc(int $dataTTL)

Garbage collector that deletes expired session data.

Parameters

int $dataTTL Data TTL in seconds