JsonObjectDriver
in package
implements
RdbObjectDriver
Store an object as a JSON string.
Objects are expected to implement JsonSerializable and JsonDeserializable.
For convenience, implement the RdbJsonObject interface.
The 'expected' parameter is required.
Table of Contents
Interfaces
- RdbObjectDriver
- Base interface for object drivers.
Properties
Methods
- __construct() : mixed
- getObject() : T|null
- Get an object from a key.
- inspect() : string|null
- Inspect the object stored in the key.
- mGetObjects() : array<string, T|null>
- Get multiple objects from a key.
- mSetObjects() : array<string|int, int>
- Set multiple objects.
- setObject() : int
- Set an object.
Properties
$rdb
protected
Rdb
$rdb
Methods
__construct()
public
__construct(Rdb $rdb) : mixed
Parameters
- $rdb : Rdb
getObject()
Get an object from a key.
public
getObject(string $key, string $expected) : T|null
Parameters
- $key : string
- $expected : string
Tags
Return values
T|nullinspect()
Inspect the object stored in the key.
public
inspect(string $key) : string|null
Parameters
- $key : string
Tags
Return values
string|null —the object class name
mGetObjects()
Get multiple objects from a key.
public
mGetObjects(array<string|int, mixed> $keys, string $expected) : array<string, T|null>
Parameters
- $keys : array<string|int, mixed>
- $expected : string
Tags
Return values
array<string, T|null>mSetObjects()
Set multiple objects.
public
mSetObjects(iterable<string|int, mixed> $items) : array<string|int, int>
Parameters
- $items : iterable<string|int, mixed>
-
[ key => object ]
Tags
Return values
array<string|int, int> —[ key => int ] object sizes in bytes
setObject()
Set an object.
public
setObject(string $key, object $value[, int|float $ttl = 0 ]) : int
Parameters
- $key : string
- $value : object
- $ttl : int|float = 0
-
seconds
Tags
Return values
int —object size in bytes