DatabaseSafePersistence
in package
implements
SafePersistenceInterface
Class DatabaseSafePersistence
Database implementation of SafePersistenceInterface using Primordyx models. Provides session storage in a database table with soft delete support.
Tags
Table of Contents
Interfaces
- SafePersistenceInterface
- Interface SafePersistenceInterface
Methods
- cleanup() : int
- Clean up expired safes.
- create() : bool
- Create a new safe record in the database.
- delete() : bool
- Soft delete a safe.
- find() : array<string|int, mixed>|null
- Find a safe record by ID, checking expiration and soft deletes.
- touch() : bool
- Touch a safe to extend expiration.
- update() : bool
- Update a 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 in the database.
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()
Soft delete a safe.
public
delete(string $safeId) : bool
Parameters
- $safeId : string
-
The safe identifier to delete
Return values
bool —True if deleted successfully
find()
Find a safe record by ID, checking expiration and soft deletes.
public
find(string $safeId) : array<string|int, mixed>|null
Parameters
- $safeId : string
-
The safe identifier to find
Tags
Return values
array<string|int, mixed>|null —Safe data array or null if not found/expired
touch()
Touch a safe to extend expiration.
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 a 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