Primordyx Framework Documentation

SafePersistenceInterface

Interface SafePersistenceInterface

Defines the contract for Safe session persistence implementations. This allows the Safe class to work with different storage backends (database, files, Redis, etc.) without tight coupling.

Tags
since
1.0.0

Table of Contents

Methods

cleanup()  : int
Clean up expired safes.
create()  : bool
Create a new safe record.
delete()  : bool
Delete a safe (soft delete preferred).
find()  : array<string|int, mixed>|null
Find and return a safe record by ID.
touch()  : bool
Touch a safe to extend its expiration without changing contents.
update()  : bool
Update an existing safe's contents and expiration.

Methods

cleanup()

Clean up expired safes.

public cleanup() : int
Return values
int

Number of safes cleaned up

create()

Create a new safe record.

public create(string $safeId, array<string|int, mixed> $contents, string $expiresAt) : bool
Parameters
$safeId : string

The unique safe identifier

$contents : array<string|int, mixed>

The initial contents (usually empty)

$expiresAt : string

The expiration timestamp

Return values
bool

True if created successfully

delete()

Delete a safe (soft delete preferred).

public delete(string $safeId) : bool
Parameters
$safeId : string

The safe identifier to delete

Return values
bool

True if deleted successfully

find()

Find and return a safe record by ID.

public find(string $safeId) : array<string|int, mixed>|null
Parameters
$safeId : string

The safe identifier to find

Return values
array<string|int, mixed>|null

Safe data array or null if not found/expired

touch()

Touch a safe to extend its expiration without changing contents.

public touch(string $safeId, string $expiresAt) : bool
Parameters
$safeId : string

The safe identifier

$expiresAt : string

The new expiration timestamp

Return values
bool

True if touched successfully

update()

Update an existing safe's contents and expiration.

public update(string $safeId, array<string|int, mixed> $contents, string $expiresAt) : bool
Parameters
$safeId : string

The safe identifier

$contents : array<string|int, mixed>

The updated contents

$expiresAt : string

The new expiration timestamp

Return values
bool

True if updated successfully


        
On this page

Search results