Skip to content

AzureTableSessionPersistence

SessionPersistenceInterface storing one entity per session id in a single Azure Table Storage table — cheaper than AzureBlobSessionPersistence for small key/value-shaped session payloads, with no per-account container to manage.

All entities share one partition (session); the session id is the row key.

final class AzureTableSessionPersistence implements SessionPersistenceInterface

ImplementsSessionPersistenceInterface
SourceAzureTableSessionPersistence.php

public function __construct(AzureTableClient $client, string $table = 'sessions', SessionCodecInterface $codec = new SessionCodec(…)): mixed

ParameterTypeDescription
$clientAzureTableClient
$tablestring
$codecSessionCodecInterface

Returns mixed

MethodDescription
delete(string $sid): voidDeletes the entity unconditionally; the table is not created for a delete, and an entity that is not there is not an error.
[`load(string $sid): array<string, mixed>null`](#load)
save(string $sid, array<string, mixed> $data): void

public function delete(string $sid): void

Deletes the entity unconditionally; the table is not created for a delete, and an entity that is not there is not an error.

Deleting an id that is not stored is not an error. Implementations decide how loudly a backend failure is reported, but must not leave the caller believing the record is gone when it demonstrably is not.

ParameterTypeDescription
$sidstring
ThrowsWhen
AzureStorageExceptionIf Azure answers with anything other than success or 404.

public function load(string $sid): array<string, mixed>|null

Reads the entity whose row key is the session id from the shared partition and decodes its Data property.

An absent entity, an entity without a Data property, or one whose Data is not a string all read as an unknown session.

ParameterTypeDescription
$sidstring

Returns array``<``string``, ``mixed``>``|``null

public function save(string $sid, array<string, mixed> $data): void

ParameterTypeDescription
$sidstring
$dataarray``<``string``, ``mixed``>