final class RedisSessionStorage implements SessionStorageInterface (View source)

Persists sliding sessions in Redis and delegates physical cleanup to key TTL.

Concurrent payload mutations use last-writer-wins semantics.

Methods

__construct(string $host = '127.0.0.1', int $port = 6379, int $database = 0, string|null $password = null, string $prefix = 'sess:', int $lifetimeSeconds = 7200, string $cookieName = 'LEMONADE_SESSION', float $timeout = 2.5, SessionCookie|null $cookie = null, Closure|null $clientFactory = null)

Defines the Redis endpoint, key namespace, sliding retention, and browser identity.

void
start()

Loads and touches a live key or replaces a missing identity with a fresh TTL-backed key.

void
bool

Reports whether this request has established its Redis-backed identity.

bool
bool
has(string $key)

Checks the payload loaded for this request.

bool
mixed
get(string $key, mixed $default = null)

Returns a loaded value or the supplied fallback.

mixed
void
set(string $key, mixed $value)

Stores a value with a renewed Redis TTL.

void
void
remove(string $key)

Removes one value and renews the Redis TTL.

void
void
clear()

Persists an empty payload while retaining the active key and cookie.

void
void

Deletes and verifies the active key, then expires its browser cookie.

void
void
regenerate(bool $deleteOldSession = true)

Copies the payload to a fresh TTL-backed key and optionally invalidates the old key.

void

Details

__construct

__construct(string $host = '127.0.0.1', int $port = 6379, int $database = 0, string|null $password = null, string $prefix = 'sess:', int $lifetimeSeconds = 7200, string $cookieName = 'LEMONADE_SESSION', float $timeout = 2.5, SessionCookie|null $cookie = null, Closure|null $clientFactory = null)

Defines the Redis endpoint, key namespace, sliding retention, and browser identity.

Parameters

string $host
int $port
int $database
string|null $password
string $prefix
int $lifetimeSeconds
string $cookieName
float $timeout
SessionCookie|null $cookie
Closure|null $clientFactory

start

void start()

Loads and touches a live key or replaces a missing identity with a fresh TTL-backed key.

Return Value

void

started

bool started()

Reports whether this request has established its Redis-backed identity.

Return Value

bool

has

bool has(string $key)

Checks the payload loaded for this request.

Parameters

string $key

Return Value

bool

get

mixed get(string $key, mixed $default = null)

Returns a loaded value or the supplied fallback.

Parameters

string $key
mixed $default

Return Value

mixed

set

void set(string $key, mixed $value)

Stores a value with a renewed Redis TTL.

Parameters

string $key
mixed $value

Return Value

void

remove

void remove(string $key)

Removes one value and renews the Redis TTL.

Parameters

string $key

Return Value

void

clear

void clear()

Persists an empty payload while retaining the active key and cookie.

Return Value

void

destroy

void destroy()

Deletes and verifies the active key, then expires its browser cookie.

Return Value

void

regenerate

void regenerate(bool $deleteOldSession = true)

Copies the payload to a fresh TTL-backed key and optionally invalidates the old key.

Parameters

bool $deleteOldSession

Return Value

void