IRepository
in
Repository interface for storing and retrieving serializable data.
The IRepository interface provides a consistent API for persisting data across different storage backends (Redis, Memory, File, etc.). It supports basic CRUD operations with optional time-to-live (TTL) for automatic expiration.
Tags
Table of Contents
Methods
- delete() : bool
- Delete a value by key.
- exists() : bool
- Check if a key exists in the repository.
- find() : mixed
- Find a value by key.
- save() : bool
- Save a value to the repository.
Methods
delete()
Delete a value by key.
public
delete(string $key) : bool
Parameters
- $key : string
-
The key to delete
Return values
bool —True if deleted, false if key didn't exist
exists()
Check if a key exists in the repository.
public
exists(string $key) : bool
Parameters
- $key : string
-
The key to check
Return values
bool —True if exists and not expired, false otherwise
find()
Find a value by key.
public
find(string $key) : mixed
Parameters
- $key : string
-
The key to look up
Return values
mixed —The stored value, or null if not found or expired
save()
Save a value to the repository.
public
save(string $key, mixed $value[, int $ttl = 0 ]) : bool
Parameters
- $key : string
-
The unique key to store the value under
- $value : mixed
-
The value to store (must be serializable)
- $ttl : int = 0
-
Time-to-live in seconds (0 = no expiration)
Return values
bool —True on success, false on failure