class Table

Relay Table is a persistent hash table shared across workers that can store arbitrary data.

Methods

static mixed
get(string $key, string|null $namespace = null)

Returns a key's value, or null if key doesn't exist.

static array|false
getWithMeta(mixed $key, string|null $namespace = null)

Get the value and metadata of key.

static bool
set(string $key, mixed $value, int|null $expire = null, string|null $namespace = null)

Sets a key and its value.

static bool
recordMetrics(string $key, int $resolution, int $retention, array $metrics, int|null $timestamp = null, string|null $namespace = null)

Records numeric values in a fixed-resolution, fixed-retention time series.

static array|false
getMetrics(string $key, int|null $from = null, int|null $to = null, string|null $namespace = null)

Returns a stats series, optionally restricted by inclusive bucket timestamps.

static bool
exists(string $key, string|null $namespace = null)

Checks if a key exists in the table.

static bool
delete(string $key, string|null $namespace = null)

Remove a key from the table.

static int|false
ttl(string $key, string|null $namespace = null)

Returns the remaining time to live of a key that has a timeout, or false if the key doesn't exist or has no timeout.

static int|false
count(string|null $namespace = null)

Returns the number of keys stored in the table.

static bool
clear(string|null $namespace = null)

Removes all keys from the table.

static array|false
keys(mixed $pattern, string|null $namespace = null)

Returns all keys matching pattern.

static int|false
memory(string|null $namespace = null)

Returns the number of bytes allocated for all elements.

static array|false
namespaces()

Returns all table namespaces.

static int|false
clearAll()

Removes all keys from all namespaces.

static Generator|false
fullscan(mixed $match = null, int $count = 0)

Scan the keyspace for matching keys on each namespace.

static array|false
stats()

Returns statistics about Table.

Details

at line 4968
static mixed get(string $key, string|null $namespace = null)

Returns a key's value, or null if key doesn't exist.

Parameters

string $key
string|null $namespace

Return Value

mixed

at line 4977
static array|false getWithMeta(mixed $key, string|null $namespace = null)

Get the value and metadata of key.

Parameters

mixed $key
string|null $namespace

Return Value

array|false

at line 4988
static bool set(string $key, mixed $value, int|null $expire = null, string|null $namespace = null)

Sets a key and its value.

Parameters

string $key
mixed $value
int|null $expire
string|null $namespace

Return Value

bool

at line 5007
static bool recordMetrics(string $key, int $resolution, int $retention, array $metrics, int|null $timestamp = null, string|null $namespace = null)

Records numeric values in a fixed-resolution, fixed-retention time series.

Field names must start with + (sum), ~ (mean), or = (last value). The timestamp, resolution, and retention are expressed in Unix milliseconds.

A null value keeps its field in the schema, but records no sample for it, leaving aggregates and the field's type untouched.

Parameters

string $key
int $resolution
int $retention
array $metrics
int|null $timestamp
string|null $namespace

Return Value

bool

at line 5033
static array|false getMetrics(string $key, int|null $from = null, int|null $to = null, string|null $namespace = null)

Returns a stats series, optionally restricted by inclusive bucket timestamps.

Fields that never held a value have no type, and buckets in which a field held no value are returned as null.

Parameters

string $key
int|null $from
int|null $to
string|null $namespace

Return Value

array|false

at line 5047
static bool exists(string $key, string|null $namespace = null)

Checks if a key exists in the table.

Parameters

string $key
string|null $namespace

Return Value

bool

at line 5056
static bool delete(string $key, string|null $namespace = null)

Remove a key from the table.

Parameters

string $key
string|null $namespace

Return Value

bool

at line 5066
static int|false ttl(string $key, string|null $namespace = null)

Returns the remaining time to live of a key that has a timeout, or false if the key doesn't exist or has no timeout.

Parameters

string $key
string|null $namespace

Return Value

int|false

at line 5074
static int|false count(string|null $namespace = null)

Returns the number of keys stored in the table.

Parameters

string|null $namespace

Return Value

int|false

at line 5082
static bool clear(string|null $namespace = null)

Removes all keys from the table.

Parameters

string|null $namespace

Return Value

bool

at line 5091
static array|false keys(mixed $pattern, string|null $namespace = null)

Returns all keys matching pattern.

Parameters

mixed $pattern
string|null $namespace

Return Value

array|false

at line 5099
static int|false memory(string|null $namespace = null)

Returns the number of bytes allocated for all elements.

Parameters

string|null $namespace

Return Value

int|false

at line 5106
static array|false namespaces()

Returns all table namespaces.

Return Value

array|false

at line 5113
static int|false clearAll()

Removes all keys from all namespaces.

Return Value

int|false

at line 5122
static Generator|false fullscan(mixed $match = null, int $count = 0)

Scan the keyspace for matching keys on each namespace.

Parameters

mixed $match
int $count

Return Value

Generator|false

at line 5129
static array|false stats()

Returns statistics about Table.

Return Value

array|false