Methods |
public
|
__construct(array|null $options = null)
Parameters
$options |
configuration options
|
|
#
|
public
|
connect(
string $host,
int $port = 6379,
float $timeout = 0,
string|null $persistent_id = null,
int $retry_interval = 0,
float $read_timeout = 0,
array|null $context = null,
): bool
Connects to a Redis instance.
Connects to a Redis instance.
Parameters
$host |
can be a host, or the path to a unix domain socket
|
$port |
optional
|
$timeout |
value in seconds (optional, default is 0.0 meaning it will use default_socket_timeout )
|
$persistent_id |
identity for the requested persistent connection
|
$retry_interval |
retry interval in milliseconds.
|
$read_timeout |
value in seconds (optional, default is 0 meaning it will use default_socket_timeout )
|
$context |
since PhpRedis >= 5.3.0 can specify authentication and stream information on connect
|
Returns
TRUE on success, FALSE on error
Throws
|
#
|
public
|
open(
string $host,
int $port = 6379,
float $timeout = 0,
string $persistent_id = null,
int $retry_interval = 0,
float $read_timeout = 0,
array $context = null,
): bool
Connects to a Redis instance.
Connects to a Redis instance.
Parameters
$host |
can be a host, or the path to a unix domain socket
|
$port |
optional
|
$timeout |
value in seconds (optional, default is 0.0 meaning it will use default_socket_timeout )
|
$persistent_id |
identity for the requested persistent connection
|
$retry_interval |
retry interval in milliseconds.
|
$read_timeout |
value in seconds (optional, default is 0 meaning it will use default_socket_timeout )
|
$context |
since PhpRedis >= 5.3.0 can specify authentication and stream information on connect
|
Returns
TRUE on success, FALSE on error
Throws
|
#
|
public
|
isConnected(): bool
A method to determine if a phpredis object thinks it's connected to a server
A method to determine if a phpredis object thinks it's connected to a server
Returns
Returns TRUE if phpredis thinks it's connected and FALSE if not
Throws
|
#
|
public
|
getHost(): string|false
Retrieve our host or unix socket that we're connected to
Retrieve our host or unix socket that we're connected to
Returns
The host or unix socket we're connected to or FALSE if we're not connected
Throws
|
#
|
public
|
getPort(): int|false
Get the port we're connected to This number will be zero if we are connected to a unix socket.
Get the port we're connected to This number will be zero if we are connected to a unix socket.
Returns
Returns the port we're connected to or FALSE if we're not connected
Throws
|
#
|
public
|
getDbNum(): int|bool
Get the database number phpredis is pointed to
Get the database number phpredis is pointed to
Returns
Returns the database number (int) phpredis thinks it's pointing to
or FALSE if we're not connected
Throws
|
#
|
public
|
getTimeout(): float|false
Get the (write) timeout in use for phpredis
Get the (write) timeout in use for phpredis
Returns
The timeout (DOUBLE) specified in our connect call or FALSE if we're not connected
Throws
|
#
|
public
|
getReadTimeout(): float|bool
Get the read timeout specified to phpredis or FALSE if we're not connected
Get the read timeout specified to phpredis or FALSE if we're not connected
Returns
Returns the read timeout (which can be set using setOption and Redis::OPT_READ_TIMEOUT)
or FALSE if we're not connected
Throws
|
#
|
public
|
getPersistentID(): string|null|bool
Gets the persistent ID that phpredis is using
Gets the persistent ID that phpredis is using
Returns
Returns the persistent id phpredis is using
(which will only be set if connected with pconnect),
NULL if we're not using a persistent ID,
and FALSE if we're not connected
Throws
|
#
|
public
|
getAuth(): mixed
Get the authentication information on the connection, if any.
Get the authentication information on the connection, if any.
Returns
The authentication information used to authenticate the connection.
Throws
|
#
|
public
|
pconnect(
string $host,
int $port = 6379,
float $timeout = 0,
string|null $persistent_id = null,
int $retry_interval = 0,
float $read_timeout = 0,
array|null $context = null,
): bool
Connects to a Redis instance or reuse a connection already established with pconnect/popen. The connection will not be closed on close or end of request until the php process ends.
So be patient on to many open FD's (specially on redis server side) when using persistent connections on
many servers connecting to one redis server. Also more than one persistent connection can be made identified by either host + port + timeout
or host + persistentId or unix socket + timeout. This feature is not available in threaded versions. pconnect and popen then working like their non persistent
equivalents.
Connects to a Redis instance or reuse a connection already established with pconnect/popen. The connection will not be closed on close or end of request until the php process ends.
So be patient on to many open FD's (specially on redis server side) when using persistent connections on
many servers connecting to one redis server. Also more than one persistent connection can be made identified by either host + port + timeout
or host + persistentId or unix socket + timeout. This feature is not available in threaded versions. pconnect and popen then working like their non persistent
equivalents.
Parameters
$host |
can be a host, or the path to a unix domain socket
|
$port |
optional
|
$timeout |
value in seconds (optional, default is 0.0 meaning it will use default_socket_timeout )
|
$persistent_id |
identity for the requested persistent connection
|
$retry_interval |
retry interval in milliseconds.
|
$read_timeout |
value in seconds (optional, default is 0 meaning it will use default_socket_timeout )
|
$context |
since PhpRedis >= 5.3.0 can specify authentication and stream information on connect
|
Returns
TRUE on success, FALSE on error.
Throws
|
#
|
public
|
popen(
string $host,
int $port = 6379,
float $timeout = 0,
string|null $persistent_id = null,
int $retry_interval = 0,
float $read_timeout = 0,
array|null $context = null,
): bool
|
#
|
public
|
close(): bool
Disconnects from the Redis instance. Note: Closing a persistent connection requires PhpRedis >= 4.2.0
Disconnects from the Redis instance. Note: Closing a persistent connection requires PhpRedis >= 4.2.0
Returns
TRUE on success, FALSE on error
Throws
|
#
|
public
|
swapdb(int $db1, int $db2): bool
Swap one Redis database with another atomically Note: Requires Redis >= 4.0.0
Swap one Redis database with another atomically Note: Requires Redis >= 4.0.0
Returns
TRUE on success and FALSE on failure
Throws
|
#
|
public
|
setOption(int $option, mixed $value): bool
Set a configurable option on the Redis object.
Set a configurable option on the Redis object.
Parameters
$option |
The option constant.
|
$value |
The option value.
|
Returns
TRUE on success, FALSE on error
Throws
|
#
|
public
|
getOption(int $option): mixed|null
Retrieve the value of a configuration setting as set by Redis::setOption()
Retrieve the value of a configuration setting as set by Redis::setOption()
Parameters
Returns
The setting itself or false on failure.
Throws
|
#
|
public
|
ping(string $message = null): bool|string
Check the current connection status
Check the current connection status
Parameters
$message |
An optional string message that Redis will reply with, if passed.
|
Returns
TRUE if the command is successful or returns message
Throws a RedisException object on connectivity error, as described above.
Throws
|
#
|
public
|
echo(string $message): string|Redis
Sends a string to Redis, which replies with the same string
Sends a string to Redis, which replies with the same string
Returns
The string sent to Redis or false on failure or Redis if in multimode
Throws
|
#
|
public
|
get(string $key): string|mixed|false|Redis
Get the value related to the specified key
Get the value related to the specified key
Returns
If key didn't exist, FALSE is returned or Redis if in multimode
Otherwise, the value related to this key is returned
Throws
|
#
|
public
|
set(string $key, mixed $value, mixed $options = null): bool|Redis
Set the string value in argument as value of the key.
Set the string value in argument as value of the key.
Parameters
$key |
The key name to set.
|
$value |
The value to set the key to.
|
$options |
Either an array with options for how to perform the set or an integer with an expiration.
If an expiration is set PhpRedis will actually send the SETEX command.
Since 2.6.12 it also supports different flags inside an array.
OPTION DESCRIPTION
['EX' => 60] expire 60 seconds.
['PX' => 6000] expire in 6000 milliseconds.
['EXAT' => time() + 10] expire in 10 seconds.
['PXAT' => time()*1000 + 1000] expire in 1 second.
['KEEPTTL' => true] Redis will not update the key's current TTL.
['XX'] Only set the key if it already exists.
['NX'] Only set the key if it doesn't exist.
['GET'] Instead of returning +OK return the previous value of the
key or NULL if the key didn't exist.
|
Returns
TRUE if the command is successful or Redis if in multimode
Throws
|
#
|
public
|
setex(string $key, int $expire, mixed $value): bool|Redis
Set the string value in argument as value of the key, with a time to live.
Set the string value in argument as value of the key, with a time to live.
Parameters
$key |
The name of the key to set.
|
$expire |
The key's expiration in seconds.
|
$value |
The value to set the key.
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
psetex(string $key, int $expire, mixed $value): bool|Redis
Set the value and expiration in milliseconds of a key.
Set the value and expiration in milliseconds of a key.
Parameters
$key |
The key to set
|
$expire |
The TTL to set, in milliseconds.
|
$value |
The value to set the key to.
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
setnx(string $key, mixed $value): bool|array|Redis
Set the string value in argument as value of the key if the key doesn't already exist in the database.
Set the string value in argument as value of the key if the key doesn't already exist in the database.
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
del(string|array $key1, string ...$otherKeys): false|int|Redis
Parameters
$key1 |
Either an array with one or more key names or a string with the name of a key.
|
...$otherKeys |
One or more additional keys passed in a variadic fashion.
|
Returns
Number of keys deleted or Redis if in multimode
Throws
|
#
|
public
|
delete(string|array $key, string ...$otherKeys): false|int|Redis
Parameters
$key |
An array of keys, or an undefined number of parameters, each a key: key1 key2 key3 ... keyN
|
Returns
Number of keys deleted or Redis if in multimode
Throws
|
#
|
public
|
unlink(string|array $key, string ...$other_keys): false|int|Redis
Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.
Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.
Parameters
$key |
An array of keys, or an undefined number of parameters, each a key: key1 key2 key3 ... keyN
|
Returns
Number of keys unlinked or Redis if in multimode
Throws
|
#
|
public
|
multi(int $mode = Redis::MULTI): static|Redis
Enter and exit transactional mode.
Enter and exit transactional mode.
Parameters
$mode |
Redis::MULTI|Redis::PIPELINE
Defaults to Redis::MULTI.
A Redis::MULTI block of commands runs as a single transaction;
a Redis::PIPELINE block is simply transmitted faster to the server, but without any guarantee of atomicity.
discard cancels a transaction.
|
Returns
returns the Redis instance and enters multi-mode or Redis if in multimode
Once in multi-mode, all subsequent method calls return the same object until exec() is called.
Throws
|
#
|
public
|
pipeline(): bool|Redis
Returns a Redis instance which can simply transmitted faster to the server.
Returns a Redis instance which can simply transmitted faster to the server.
Returns
returns the Redis instance.
Once in pipeline-mode, all subsequent method calls return the same object until exec() is called.
Pay attention, that Pipeline is not a transaction, so you can get unexpected
results in case of big pipelines and small read/write timeouts.
Throws
|
#
|
public
|
exec(): array|false|Redis
Execute either a MULTI or PIPELINE block and return the array of replies.
Execute either a MULTI or PIPELINE block and return the array of replies.
Returns
The array of pipeline'd or multi replies or false on failure or Redis if in multimode
Throws
|
#
|
public
|
discard(): bool|Redis
Flushes all previously queued commands in a transaction and restores the connection state to normal.
Flushes all previously queued commands in a transaction and restores the connection state to normal.
Returns
True if we could discard the transaction or Redis if in multimode
Throws
|
#
|
public
|
watch(string|array $key, string ...$other_keys): bool|Redis
Watches a key for modifications by another client. If the key is modified between WATCH and EXEC,
the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client.
Watches a key for modifications by another client. If the key is modified between WATCH and EXEC,
the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client.
Parameters
$key |
Either an array with one or more key names, or a string key name
|
...$other_keys |
If the first argument was passed as a string, any number of
additional string key names may be passed variadically.
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
unwatch(): bool|Redis
Remove any previously WATCH'ed keys in a transaction.
Remove any previously WATCH'ed keys in a transaction.
Throws
|
#
|
public
|
subscribe(array|string $channels, callable $callback): false|array|Redis
Subscribes the client to the specified channels. Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional SUBSCRIBE, SSUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, SUNSUBSCRIBE, PUNSUBSCRIBE, PING, RESET and QUIT commands.
Subscribes the client to the specified channels. Once the client enters the subscribed state it is not supposed to issue any other commands, except for additional SUBSCRIBE, SSUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, SUNSUBSCRIBE, PUNSUBSCRIBE, PING, RESET and QUIT commands.
Parameters
$channels |
One or more channel names.
|
$callback |
The callback PhpRedis will invoke when we receive a message from one of the subscribed channels.
|
Returns
False on faiilure. Note that this command will block the client in a subscribe loop, waiting for messages to arrive
Throws
|
#
|
public
|
psubscribe(array $patterns, string|array|callable $callback): mixed|Redis
Subscribe to channels by pattern
Subscribe to channels by pattern
Parameters
$patterns |
an array of glob-style patterns to subscribe
|
$callback |
Either a string or an array with an object and method.
The callback will get four arguments ($redis, $pattern, $channel, $message)
|
Returns
Any non-null return value in the callback will be returned to the caller or Redis if in multimode
Throws
|
#
|
public
|
publish(string $channel, string $message): false|int|Redis
Publish messages to channels. Warning: this function will probably change in the future.
Publish messages to channels. Warning: this function will probably change in the future.
Parameters
$channel |
The channel to publish to.
|
$message |
The message itself.
|
Returns
Number of clients that received the message or Redis if in multimode
Throws
|
#
|
public
|
pubsub(string $keyword, mixed $argument = null): mixed|Redis
A command allowing you to get information on the Redis pub/sub system
A command allowing you to get information on the Redis pub/sub system
Parameters
$keyword |
String, which can be: "channels", "numsub", or "numpat"
|
$argument |
Optional, variant.
For the "channels" subcommand, you can pass a string pattern.
For "numsub" an array of channel names
|
Returns
Either an integer or an array or Redis if in multimode
- channels Returns an array where the members are the matching channels.
- numsub Returns a key/value array where the keys are channel names and
values are their counts.
- numpat Integer return containing the number active pattern subscriptions
Throws
|
#
|
public
|
unsubscribe(array $channels): bool|array|Redis
Stop listening for messages posted to the given channels.
Stop listening for messages posted to the given channels.
Parameters
$channels |
One or more channels to unsubscribe from.
|
Returns
The array of unsubscribed channels.
Throws
|
#
|
public
|
punsubscribe(array $patterns): false|array
Stop listening for messages posted to the given channels.
Stop listening for messages posted to the given channels.
Parameters
$patterns |
an array of glob-style patterns to unsubscribe
|
Throws
|
#
|
public
|
exists(mixed $key, mixed ...$other_keys): int|bool|Redis
Verify if the specified key/keys exists This function took a single argument and returned TRUE or FALSE in phpredis versions < 4.0.0.
Verify if the specified key/keys exists This function took a single argument and returned TRUE or FALSE in phpredis versions < 4.0.0.
Parameters
$key |
Either an array of keys or a string key
|
...$other_keys |
If the previous argument was a string, you may send any number of additional keys to test.
|
Returns
The number of keys tested that do exist or Redis if in multimode
Throws
|
#
|
public
|
incr(string $key, int $by = 1): false|int|Redis
Increment the number stored at key by one.
Increment the number stored at key by one.
Parameters
$key |
The key to increment
|
$by |
An optional amount to increment by.
|
Returns
the new value or Redis if in multimode
Throws
|
#
|
public
|
incrByFloat(string $key, float $increment): float|false|Redis
Increment the float value of a key by the given amount
Increment the float value of a key by the given amount
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
incrBy(string $key, int $value): false|int|Redis
Increment the number stored at key by one.
Increment the number stored at key by one.
Parameters
$key |
The key to increment.
|
$value |
The amount to increment.
|
Returns
the new value or Redis if in multimode
Throws
|
#
|
public
|
decr(string $key, int $by = 1): false|int|Redis
Decrement the number stored at key by one.
Decrement the number stored at key by one.
Parameters
$key |
The key to decrement
|
$by |
How much to decrement the key. Note that if this value is not sent or is set to 1
|
Returns
The new value of the key or false on failure or Redis if in multimode
Throws
|
#
|
public
|
decrBy(string $key, int $value): false|int|Redis
Decrement the number stored at key by one.
Decrement the number stored at key by one.
Parameters
$key |
The integer key to decrement.
|
$value |
How much to decrement the key.
|
Returns
The new value of the key or false on failure or Redis if in multimode
Throws
|
#
|
public
|
lPush(string $key, mixed ...$value1): int|false|Redis
Adds the string values to the head (left) of the list.
Creates the list if the key didn't exist.
If the key exists and is not a list, FALSE is returned.
Adds the string values to the head (left) of the list.
Creates the list if the key didn't exist.
If the key exists and is not a list, FALSE is returned.
Parameters
$key |
The list to prepend.
|
...$value1 |
One or more elements to prepend.
|
Returns
The new length of the list in case of success, FALSE in case of Failure or Redis if in multimode
Throws
|
#
|
public
|
rPush(string $key, mixed ...$value1): int|false|Redis
Adds the string values to the tail (right) of the list.
Creates the list if the key didn't exist.
If the key exists and is not a list, FALSE is returned.
Adds the string values to the tail (right) of the list.
Creates the list if the key didn't exist.
If the key exists and is not a list, FALSE is returned.
Parameters
$key |
The list to append to.
|
...$value1 |
one or more elements to append.
|
Returns
The new length of the list in case of success, FALSE in case of Failure or Redis if in multimode
Throws
|
#
|
public
|
lPushx(string $key, mixed $value): int|false|Redis
Adds the string value to the head (left) of the list if the list exists.
Adds the string value to the head (left) of the list if the list exists.
Parameters
$key |
The key to prepend to.
|
$value |
The value to prepend.
|
Returns
The new length of the list in case of success, FALSE in case of Failure or Redis if in multimode
Throws
|
#
|
public
|
rPushx(string $key, mixed $value): int|false|Redis
Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure.
Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure.
Parameters
$key |
The key to prepend to.
|
$value |
The value to prepend.
|
Returns
The new length of the list in case of success, FALSE in case of Failure or Redis if in multimode
Throws
|
#
|
public
|
lPop(string $key, int $count = 0): mixed|bool|Redis
Returns and removes the first element of the list.
Returns and removes the first element of the list.
Parameters
$key |
The list to pop from.
|
$count |
Optional number of elements to remove. By default one element is popped.
|
Returns
if command executed successfully BOOL FALSE in case of failure (empty list) or Redis if in multimode
Throws
|
#
|
public
|
rPop(string $key, int $count = 0): mixed|array|string|bool|Redis
Returns and removes the last element of the list.
Returns and removes the last element of the list.
Parameters
$key |
A redis LIST key name.
|
$count |
The maximum number of elements to pop at once. NOTE: The count argument requires Redis >= 6.2.0
|
Returns
if command executed successfully BOOL FALSE in case of failure (empty list) or Redis if in multimode
Throws
|
#
|
public
|
blPop(string|string[] $key_or_keys, string|float|int $timeout_or_key, mixed ...$extra_args): array|null|false|Redis
Is a blocking lPop primitive. If at least one of the lists contains at least one element,
the element will be popped from the head of the list and returned to the caller.
Il all the list identified by the keys passed in arguments are empty, blPop will block
during the specified timeout until an element is pushed to one of those lists. This element will be popped.
Is a blocking lPop primitive. If at least one of the lists contains at least one element,
the element will be popped from the head of the list and returned to the caller.
Il all the list identified by the keys passed in arguments are empty, blPop will block
during the specified timeout until an element is pushed to one of those lists. This element will be popped.
Parameters
$key_or_keys |
String array containing the keys of the lists OR variadic list of strings
|
$timeout_or_key |
Timeout is always the required final parameter
|
Returns
Can return various things depending on command and data or Redis if in multimode
Throws
|
#
|
public
|
brPop(string|string[] $key_or_keys, string|float|int $timeout_or_key, mixed ...$extra_args): array|null|true|Redis
Is a blocking rPop primitive. If at least one of the lists contains at least one element,
the element will be popped from the head of the list and returned to the caller.
Il all the list identified by the keys passed in arguments are empty, brPop will
block during the specified timeout until an element is pushed to one of those lists.
This element will be popped.
Is a blocking rPop primitive. If at least one of the lists contains at least one element,
the element will be popped from the head of the list and returned to the caller.
Il all the list identified by the keys passed in arguments are empty, brPop will
block during the specified timeout until an element is pushed to one of those lists.
This element will be popped.
Parameters
$key_or_keys |
String array containing the keys of the lists OR variadic list of strings
|
$timeout_or_key |
Timeout is always the required final parameter
|
Returns
Can return various things depending on command and data or Redis if in multimode
Throws
|
#
|
public
|
lLen(string $key): int|bool|Redis
Returns the size of a list identified by Key. If the list didn't exist or is empty,
the command returns 0. If the data type identified by Key is not a list, the command return FALSE.
Returns the size of a list identified by Key. If the list didn't exist or is empty,
the command returns 0. If the data type identified by Key is not a list, the command return FALSE.
Returns
The size of the list identified by Key exists or Redis if in multimode
bool FALSE if the data type identified by Key is not list
Throws
|
#
|
public
|
lSize(string $key): false|int|Redis
Returns
The size of the list identified by Key exists or Redis if in multimode
Throws
|
#
|
public
|
lIndex(string $key, int $index): mixed|bool|Redis
Return the specified element of the list stored at the specified key.
0 the first element, 1 the second ... -1 the last element, -2 the penultimate ...
Return FALSE in case of a bad index or a key that doesn't point to a list.
Return the specified element of the list stored at the specified key.
0 the first element, 1 the second ... -1 the last element, -2 the penultimate ...
Return FALSE in case of a bad index or a key that doesn't point to a list.
Returns
the element at this index or Redis if in multimode
Throws
|
#
|
public
|
lGet(string $key, int $index): mixed|bool|Redis
Returns
the element at this index or Redis if in multimode
Throws
|
#
|
public
|
lSet(string $key, int $index, mixed $value): bool|Redis
Set the list at index with the new value.
Set the list at index with the new value.
Parameters
$key |
The list to modify.
|
$index |
The position of the element to change.
|
$value |
The new value.
|
Returns
TRUE if the new value is setted or Redis if in multimode
FALSE if the index is out of range, or data type identified by key is not a list.
Throws
|
#
|
public
|
lRange(string $key, int $start, int $end): array|Redis
Returns the specified elements of the list stored at the specified key in
the range [start, end]. start and stop are interpretated as indices: 0 the first element,
1 the second ... -1 the last element, -2 the penultimate ...
Returns the specified elements of the list stored at the specified key in
the range [start, end]. start and stop are interpretated as indices: 0 the first element,
1 the second ... -1 the last element, -2 the penultimate ...
Parameters
$key |
The list to query.
|
$start |
The beginning index to retrieve. This number can be negative meaning start from the end of the list.
|
$end |
The end index to retrieve. This can also be negative to start from the end of the list.
|
Returns
containing the values in specified range or Redis if in multimode
Throws
|
#
|
public
|
lGetRange(string $key, int $start, int $end): array|Redis
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
lTrim(string $key, int $start, int $end): array|false|Redis
Trims an existing list so that it will contain only a specified range of elements.
Trims an existing list so that it will contain only a specified range of elements.
Parameters
$key |
The list to trim
|
$start |
The starting index to keep
|
$end |
The ending index to keep.
|
Returns
Bool return FALSE if the key identify a non-list value or Redis if in multimode
Throws
|
#
|
public
|
listTrim(string $key, int $start, int $stop)
|
#
|
public
|
lRem(string $key, mixed $value, int $count = 0): int|bool|Redis
Removes the first count occurrences of the value element from the list.
If count is zero, all the matching elements are removed. If count is negative,
elements are removed from tail to head.
Removes the first count occurrences of the value element from the list.
If count is zero, all the matching elements are removed. If count is negative,
elements are removed from tail to head.
Parameters
$key |
The list to truncate.
|
$value |
The value to remove.
|
$count |
How many elements matching the value to remove.
|
Returns
the number of elements to remove or Redis if in multimode
bool FALSE if the value identified by key is not a list.
Throws
|
#
|
public
|
lRemove(string $key, string $value, int $count)
|
#
|
public
|
lInsert(string $key, string $position, mixed $pivot, mixed $value): false|int|Redis
Insert value in the list before or after the pivot value. the parameter options
specify the position of the insert (before or after). If the list didn't exists,
or the pivot didn't exists, the value is not inserted.
Insert value in the list before or after the pivot value. the parameter options
specify the position of the insert (before or after). If the list didn't exists,
or the pivot didn't exists, the value is not inserted.
Parameters
$position |
Redis::BEFORE | Redis::AFTER
|
Returns
The number of the elements in the list, -1 if the pivot didn't exists or Redis if in multimode
Throws
|
#
|
public
|
sAdd(string $key, mixed $value, mixed ...$other_values): int|bool|Redis
Adds a values to the set value stored at key.
Adds a values to the set value stored at key.
Parameters
$key |
Required key
|
...$other_values |
Variadic list of values
|
Returns
The number of elements added to the set or Redis if in multimode
If this value is already in the set, FALSE is returned
|
#
|
public
|
sRem(string $key, mixed $value, mixed ...$other_values): false|int|Redis
Removes the specified members from the set value stored at key.
Removes the specified members from the set value stored at key.
Parameters
...$other_values |
Variadic list of members
|
Returns
The number of elements removed from the set or Redis if in multimode
|
#
|
public
|
sRemove(string $key, string|mixed ...$member1)
|
#
|
public
|
sMove(string $srcKey, string $dstKey, mixed $member): bool|Redis
Moves the specified member from the set at srcKey to the set at dstKey.
Moves the specified member from the set at srcKey to the set at dstKey.
Returns
If the operation is successful, return TRUE or Redis if in multimode
If the srcKey and/or dstKey didn't exist, and/or the member didn't exist in srcKey, FALSE is returned.
Throws
|
#
|
public
|
sIsMember(string $key, mixed $value): bool|Redis
Checks if value is a member of the set stored at the key key.
Checks if value is a member of the set stored at the key key.
Returns
TRUE if value is a member of the set at key key, FALSE otherwise or Redis if in multimode
Throws
|
#
|
public
|
sContains(string $key, string|mixed $value)
|
#
|
public
|
sCard(string $key): false|int|Redis
Returns the cardinality of the set identified by key.
Returns the cardinality of the set identified by key.
Returns
the cardinality of the set identified by key, 0 if the set doesn't exist or Redis if in multimode
Throws
|
#
|
public
|
sPop(string $key, int $count = 0): string|mixed|array|bool|Redis
Removes and returns a random element from the set value at Key.
Removes and returns a random element from the set value at Key.
Parameters
$key |
The set in question.
|
$count |
An optional number of members to pop. This defaults to removing one element.
|
Returns
"popped" values or Redis if in multimode
bool FALSE if set identified by key is empty or doesn't exist.
Throws
|
#
|
public
|
sRandMember(string $key, int $count = 0): string|mixed|array|bool|Redis
Returns a random element(s) from the set value at Key, without removing it.
Returns a random element(s) from the set value at Key, without removing it.
Parameters
$key |
The set to query.
|
$count |
An optional count of members to return.
|
Returns
value(s) from the set or Redis if in multimode
bool FALSE if set identified by key is empty or doesn't exist and count argument isn't passed.
Throws
|
#
|
public
|
sInter(string $key1, string ...$otherKeys): array|false|Redis
Returns the members of a set resulting from the intersection of all the sets
held at the specified keys. If just a single key is specified, then this command
produces the members of this set. If one of the keys is missing, FALSE is returned.
Returns the members of a set resulting from the intersection of all the sets
held at the specified keys. If just a single key is specified, then this command
produces the members of this set. If one of the keys is missing, FALSE is returned.
Parameters
$key1 |
keys identifying the different sets on which we will apply the intersection.
|
...$otherKeys |
variadic list of keys
|
Returns
contain the result of the intersection between those keys or Redis if in multimode
If the intersection between the different sets is empty, the return value will be empty array.
Throws
|
#
|
public
|
sInterStore(array|string $key, string ...$otherKeys): int|false|Redis
Performs a sInter command and stores the result in a new set.
Performs a sInter command and stores the result in a new set.
Parameters
$key |
Either a string key, or an array of keys (with at least two elements,
consisting of the destination key name and one or more source keys names.
|
...$otherKeys |
If the first argument was a string, subsequent arguments should be source key names.
|
Returns
The cardinality of the resulting set, or FALSE in case of a missing key or Redis if in multimode
Throws
|
#
|
public
|
sUnion(string $key1, string ...$otherKeys): array|false|Redis
Performs the union between N sets and returns it.
Performs the union between N sets and returns it.
Parameters
$key1 |
first key for union
|
...$otherKeys |
variadic list of keys corresponding to sets in redis
|
Returns
The union of all these sets or Redis if in multimode
Throws
|
#
|
public
|
sUnionStore(string $dstKey, string $key1, string ...$otherKeys): false|int|Redis
Performs the same action as sUnion, but stores the result in the first key
Performs the same action as sUnion, but stores the result in the first key
Parameters
$dstKey |
The destination key
|
$key1 |
The first source key
|
...$otherKeys |
One or more additional source keys
|
Returns
Any number of keys corresponding to sets in redis or Redis if in multimode
Throws
|
#
|
public
|
sDiff(string $key1, string ...$otherKeys): array|false|Redis
Performs the difference between N sets and returns it.
Performs the difference between N sets and returns it.
Parameters
$key1 |
first key for diff
|
...$otherKeys |
variadic list of keys corresponding to sets in redis
|
Returns
string[] The difference of the first set will all the others or Redis if in multimode
Throws
|
#
|
public
|
sDiffStore(string $dstKey, string $key1, string ...$otherKeys): int|false|Redis
Performs the same action as sDiff, but stores the result in the first key
Performs the same action as sDiff, but stores the result in the first key
Parameters
$dstKey |
the key to store the diff into.
|
$key1 |
first key for diff
|
...$otherKeys |
variadic list of keys corresponding to sets in redis
|
Returns
The cardinality of the resulting set, or FALSE in case of a missing key or Redis if in multimode
Throws
|
#
|
public
|
sMembers(string $key): array|false|Redis
Returns the contents of a set.
Returns the contents of a set.
Returns
An array of elements, the contents of the set or Redis if in multimode
Throws
|
#
|
public
|
sMisMember(string $key, string $member, string ...$other_members): Redis|array|false
Check if one or more values are members of a set.
Check if one or more values are members of a set.
Parameters
$key |
The set to query.
|
$member |
The first value to test if exists in the set.
|
...$other_members |
Any number of additional values to check.
|
Returns
An array of integers representing whether each passed value was a member of the set.
|
#
|
public
|
sGetMembers(string $key): array|Redis
Returns
An array of elements, the contents of the set or Redis if in multimode
Throws
|
#
|
public
|
sScan(string $key, int|null &$iterator, string $pattern = null, int $count = 0): array|false|Redis
Parameters
$key |
The Redis SET key in question.
|
$iterator |
A reference to an iterator which should be initialized to NULL that
PhpRedis will update with the value returned from Redis after each
subsequent call to SSCAN. Once this cursor is zero you know all
members have been traversed.
|
$pattern |
An optional glob style pattern to match against, so Redis only
returns the subset of members matching this pattern.
|
$count |
A hint to Redis as to how many members it should scan in one command
before returning members for that iteration.
|
Returns
PHPRedis will return an array of keys or FALSE when we're done iterating or Redis if in multimode
Throws
|
#
|
public
|
getSet(string $key, mixed $value): string|mixed|false|Redis
Sets a value and returns the previous entry at that key.
Sets a value and returns the previous entry at that key.
Returns
A string (mixed, if used serializer), the previous value located at this key or false if it didn't exist or Redis if in multimode
Throws
|
#
|
public
|
randomKey(): string|false|Redis
Returns
an existing key in redis or Redis if in multimode
Throws
|
#
|
public
|
select(int $dbIndex): bool|Redis
Switches to a given database
Switches to a given database
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
move(string $key, int $dbIndex): bool|Redis
Moves a key to a different database.
Moves a key to a different database.
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
rename(string $srcKey, string $dstKey): bool|Redis
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
renameKey(string $srcKey, string $dstKey)
|
#
|
public
|
renameNx(string $srcKey, string $dstKey): bool|Redis
Renames a key Same as rename, but will not replace a key if the destination already exists.
This is the same behaviour as setnx.
Renames a key Same as rename, but will not replace a key if the destination already exists.
This is the same behaviour as setnx.
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
expire(string $key, int $ttl, string|null $mode = null): bool|Redis
Sets an expiration in seconds on the key in question. If connected to
redis-server >= 7.0.0 you may send an additional "mode" argument which
modifies how the command will execute.
Sets an expiration in seconds on the key in question. If connected to
redis-server >= 7.0.0 you may send an additional "mode" argument which
modifies how the command will execute.
Parameters
$key |
The key to set an expiration on.
|
$ttl |
The key's remaining Time To Live, in seconds
|
$mode |
A two character modifier that changes how the command works.
NX - Set expiry only if key has no expiry
XX - Set expiry only if key has an expiry
LT - Set expiry only when new expiry is < current expiry
GT - Set expiry only when new expiry is > current expiry
|
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
pExpire(string $key, int $ttl, string|null $mode = null): bool|Redis
Sets an expiration date (a timeout in milliseconds) on an item If connected to Redis >= 7.0.0 you can pass an optional mode argument that modifies how the command will execute.
Sets an expiration date (a timeout in milliseconds) on an item If connected to Redis >= 7.0.0 you can pass an optional mode argument that modifies how the command will execute.
Parameters
$key |
The key to set an expiration on.
|
$ttl |
The key's remaining Time To Live, in milliseconds
|
$mode |
A two character modifier that changes how the command works.
|
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
setTimeout(string $key, int $ttl): bool|Redis
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
expireAt(string $key, int $timestamp, string|null $mode = null): bool|Redis
Sets an expiration date (a timestamp) on an item. If connected to Redis >= 7.0.0 you can pass an optional 'mode' argument.
Sets an expiration date (a timestamp) on an item. If connected to Redis >= 7.0.0 you can pass an optional 'mode' argument.
Parameters
$key |
The key to set an expiration on.
|
$timestamp |
The unix timestamp to expire at.
|
$mode |
An option 'mode' that modifies how the command acts
|
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
pExpireAt(string $key, int $timestamp, string|null $mode = null): bool|Redis
Sets an expiration date (a timestamp) on an item. Requires a timestamp in milliseconds If connected to Redis >= 7.0.0 you can pass an optional 'mode' argument.
Sets an expiration date (a timestamp) on an item. Requires a timestamp in milliseconds If connected to Redis >= 7.0.0 you can pass an optional 'mode' argument.
Parameters
$key |
The key to set an expiration on.
|
$timestamp |
Unix timestamp. The key's date of death, in seconds from Epoch time
|
$mode |
A two character modifier that changes how the command works.
|
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
keys(string $pattern): list<string>|false|Redis
Returns the keys that match a certain pattern.
Returns the keys that match a certain pattern.
Parameters
$pattern |
pattern, using '*' as a wildcard
|
Returns
The keys that match a certain pattern or Redis if in multimode
Throws
|
#
|
public
|
getKeys(string $pattern)
|
#
|
public
|
dbSize(): false|int|Redis
Returns the current database's size
Returns the current database's size
Returns
DB size, in number of keys or Redis if in multimode
Throws
|
#
|
public
|
auth(mixed $credentials): bool|Redis
Authenticate a Redis connection after its been established.
Warning: The password is sent in plain-text over the network.
Authenticate a Redis connection after its been established.
Warning: The password is sent in plain-text over the network.
Parameters
$credentials |
A string password, or an array with one or two string elements.
|
Returns
TRUE if the connection is authenticated, FALSE otherwise or Redis if in multimode
Throws
|
#
|
public
|
bgrewriteaof(): bool|Redis
Starts the background rewrite of AOF (Append-Only File)
Starts the background rewrite of AOF (Append-Only File)
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
slaveof(string $host = '127.0.0.1', int $port = 6379): bool|Redis
Changes the slave status
Either host and port, or no parameter to stop being a slave. This method and the corresponding command in Redis has been marked deprecated
and users should instead use replicaof() if connecting to redis-server >= 5.0.0.
Changes the slave status
Either host and port, or no parameter to stop being a slave. This method and the corresponding command in Redis has been marked deprecated
and users should instead use replicaof() if connecting to redis-server >= 5.0.0.
Parameters
$host |
[optional]
|
$port |
[optional]
|
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
slowLog(string $operation, int $length = 0): mixed|Redis
Parameters
$operation |
The operation you wish to perform. This can be one of the following values:
'GET' - Retrieve the Redis slowlog as an array.
'LEN' - Retrieve the length of the slowlog.
'RESET' - Remove all slowlog entries.
|
$length |
This optional argument can be passed when operation
is 'get' and will specify how many elements to retrieve.
If omitted Redis will send up to a default number of
entries, which is configurable.
|
Returns
The return value of SLOWLOG will depend on which operation was performed or Redis if in multimode
- SLOWLOG GET: Array of slowLog entries, as provided by Redis
- SLOGLOG LEN: Integer, the length of the slowLog
- SLOWLOG RESET: Boolean, depending on success
Throws
|
#
|
public
|
object(string $subcommand, string $key): string|int|false|Redis
Describes the object pointed to by a key.
The information to retrieve (string) and the key (string).
Info can be one of the following:
- "encoding"
- "refcount"
- "idletime"
Describes the object pointed to by a key.
The information to retrieve (string) and the key (string).
Info can be one of the following:
- "encoding"
- "refcount"
- "idletime"
Returns
for "encoding", int for "refcount" and "idletime", FALSE if the key doesn't exist or Redis if in multimode
Throws
|
#
|
public
|
save(): bool|Redis
Performs a synchronous save.
Performs a synchronous save.
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
If a save is already running, this command will fail and return FALSE.
Throws
|
#
|
public
|
bgSave(): bool|Redis
Performs a background save.
Performs a background save.
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
If a save is already running, this command will fail and return FALSE
Throws
|
#
|
public
|
lastSave(): false|int|Redis
Returns the timestamp of the last disk save.
Returns the timestamp of the last disk save.
Returns
timestamp or Redis if in multimode
Throws
|
#
|
public
|
wait(int $numreplicas, int $timeout): int|false|Redis
Blocks the current client until all the previous write commands are successfully transferred and
acknowledged by at least the specified number of slaves.
Blocks the current client until all the previous write commands are successfully transferred and
acknowledged by at least the specified number of slaves.
Parameters
$numreplicas |
The number of replicas we want to confirm write operaions
|
$timeout |
How long to wait (zero meaning forever).
|
Returns
The command returns the number of slaves reached by all the writes performed in the or Redis if in multimode
context of the current connection
Throws
|
#
|
public
|
type(string $key): false|int|Redis
Returns the type of data pointed by a given key.
Returns the type of data pointed by a given key.
Returns
returns Redis if in multimode
Depending on the type of the data pointed by the key,
this method will return the following value:
- string: Redis::REDIS_STRING
- set: Redis::REDIS_SET
- list: Redis::REDIS_LIST
- zset: Redis::REDIS_ZSET
- hash: Redis::REDIS_HASH
- stream: Redis::REDIS_STREAM
- other: Redis::REDIS_NOT_FOUND
Throws
|
#
|
public
|
append(string $key, mixed $value): false|int|Redis
Append specified string to the string stored in specified key.
Append specified string to the string stored in specified key.
Returns
Size of the value after the append or Redis if in multimode
Throws
|
#
|
public
|
getRange(string $key, int $start, int $end): string|Redis
Return a substring of a larger string
Return a substring of a larger string
Returns
the substring or Redis if in multimode
Throws
|
#
|
public
|
substr(string $key, int $start, int $end)
Return a substring of a larger string
Return a substring of a larger string
Throws
|
#
|
public
|
setRange(string $key, int $offset, string $value): false|int|Redis
Changes a substring of a larger string.
Changes a substring of a larger string.
Returns
the length of the string after it was modified or Redis if in multimode
Throws
|
#
|
public
|
strlen(string $key): false|int|Redis
Get the length of a string value.
Get the length of a string value.
Returns
The length of the string key if it exists, zero if it does not, and false on failure.
Throws
|
#
|
public
|
bitpos(string $key, bool $bit, int $start = 0, int $end = -1, bool $bybit = false): false|int|Redis
Return the position of the first bit set to 1 or 0 in a string. The position is returned, thinking of the
string as an array of bits from left to right, where the first byte's most significant bit is at position 0,
the second byte's most significant bit is at position 8, and so forth.
Return the position of the first bit set to 1 or 0 in a string. The position is returned, thinking of the
string as an array of bits from left to right, where the first byte's most significant bit is at position 0,
the second byte's most significant bit is at position 8, and so forth.
Parameters
$key |
The key to check (must be a string)
|
$bit |
Whether to look for an unset (0) or set (1) bit.
|
$start |
Where in the string to start looking.
|
$end |
Where in the string to stop looking.
|
$bybit |
If true, Redis will treat $start and $end as BIT values and not bytes, so if start was 0 and end was 2, Redis would only search the first two bits.
|
Returns
The command returns the position of the first bit set to 1 or 0 according to the request or Redis if in multimode
If we look for set bits (the bit argument is 1) and the string is empty or composed of just
zero bytes, -1 is returned. If we look for clear bits (the bit argument is 0) and the string
only contains bit set to 1, the function returns the first bit not part of the string on the
right. So if the string is three bytes set to the value 0xff the command BITPOS key 0 will
return 24, since up to bit 23 all the bits are 1. Basically, the function considers the right
of the string as padded with zeros if you look for clear bits and specify no range or the
start argument only. However, this behavior changes if you are looking for clear bits and
specify a range with both start and end. If no clear bit is found in the specified range, the
function returns -1 as the user specified a clear range and there are no 0 bits in that range.
Throws
|
#
|
public
|
getBit(string $key, int $offset): false|int|Redis
Return a single bit out of a larger string
Return a single bit out of a larger string
Returns
the bit value (0 or 1) or Redis if in multimode
Throws
|
#
|
public
|
setBit(string $key, int $offset, bool|int $value): false|int|Redis
Changes a single bit of a string.
Changes a single bit of a string.
Parameters
$value |
bool or int (1 or 0)
|
Returns
0 or 1, the value of the bit before it was set or Redis if in multimode
Throws
|
#
|
public
|
bitCount(string $key, int $start = 0, int $end = -1, bool $bybit = false): false|int|Redis
Parameters
$key |
The key in question (must be a string key)
|
$start |
The index where Redis should start counting. If omitted it defaults to zero, which means the start of the string.
|
$end |
The index where Redis should stop counting. If omitted it defaults to -1, meaning the very end of the string.
|
$bybit |
Whether or not Redis should treat $start and $end as bit positions, rather than bytes.
|
Returns
The number of bits set to 1 in the value behind the input key or Redis if in multimode
Throws
|
#
|
public
|
bitOp(string $operation, string $retKey, string $key1, string ...$otherKeys): false|int|Redis
Bitwise operation on multiple keys.
Bitwise operation on multiple keys.
Parameters
$operation |
either "AND", "OR", "NOT", "XOR"
|
$retKey |
return key
|
$key1 |
first key
|
...$otherKeys |
variadic list of keys
|
Returns
The size of the string stored in the destination key or Redis if in multimode
Throws
|
#
|
public
|
flushDB(bool|null $async = null): bool|Redis
Removes all entries from the current database.
Removes all entries from the current database.
Parameters
$async |
Whether to perform the task in a blocking or non-blocking way. Requires server version 4.0.0 or greater
|
Returns
Always TRUE or Redis if in multimode
Throws
|
#
|
public
|
flushAll(bool|null $async = null): bool|Redis
Removes all entries from all databases.
Removes all entries from all databases.
Parameters
$async |
Whether to perform the task in a blocking or non-blocking way. Requires server version 4.0.0 or greater
|
Returns
Always TRUE or Redis if in multimode
Throws
|
#
|
public
|
sort(string $key, array|null $options = null): mixed
Sort the contents of a Redis key in various ways.
Sort the contents of a Redis key in various ways.
Parameters
$key |
The key you wish to sort
|
$options |
Various options controlling how you would like the data sorted.
See blow for a detailed description of this options array.
'SORT' => 'ASC'|| 'DESC' // Sort in descending or descending order.
'ALPHA' => true || false // Whether to sort alphanumerically.
'LIMIT' => [0, 10] // Return a subset of the data at offset, count
'BY' => 'weight_' // For each element in the key, read data from the
external key weight_ and sort based on that value.
'GET' => 'weight_' // For each element in the source key, retrieve the
data from key weight_ and return that in the result
rather than the source keys' element. This can
be used in combination with 'BY'
|
Returns
This command can either return an array with the sorted data or the
number of elements placed in a destination set when using the STORE option.
Throws
|
#
|
public
|
info(string ...$sections): array|false|Redis
Returns an associative array of strings and integers If connected to Redis server >= 7.0.0 you may pass multiple optional sections.
Returns an associative array of strings and integers If connected to Redis server >= 7.0.0 you may pass multiple optional sections.
Parameters
...$sections |
Optional section(s) you wish Redis server to return.
SERVER | CLIENTS | MEMORY | PERSISTENCE | STATS | REPLICATION | CPU | CLUSTER | KEYSPACE | COMMANDSTATS
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
role(): mixed|Redis
Returns an indexed array whose first element is the role
Returns an indexed array whose first element is the role
Returns
Will return an array with the role of the connected instance unless there is an error. returns Redis if in multimode
Throws
|
#
|
public
|
resetStat(): bool|Redis
Resets the statistics reported by Redis using the INFO command (info() function).
These are the counters that are reset:
- Keyspace hits
- Keyspace misses
- Number of commands processed
- Number of connections received
- Number of expired keys
Resets the statistics reported by Redis using the INFO command (info() function).
These are the counters that are reset:
- Keyspace hits
- Keyspace misses
- Number of commands processed
- Number of connections received
- Number of expired keys
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
ttl(string $key): int|bool|Redis
Returns the time to live left for a given key, in seconds. If the key doesn't exist, FALSE is returned.
Returns the time to live left for a given key, in seconds. If the key doesn't exist, FALSE is returned.
Returns
the time left to live in seconds or Redis if in multimode
Throws
|
#
|
public
|
pttl(string $key): int|bool|Redis
Returns a time to live left for a given key, in milliseconds. If the key doesn't exist, FALSE is returned.
Returns a time to live left for a given key, in milliseconds. If the key doesn't exist, FALSE is returned.
Returns
the time left to live in milliseconds or Redis if in multimode
Throws
|
#
|
public
|
persist(string $key): bool|Redis
Remove the expiration timer from a key.
Remove the expiration timer from a key.
Returns
TRUE if a timeout was removed, FALSE if the key didn’t exist or didn’t have an expiration timer or Redis if in multimode
Throws
|
#
|
public
|
mSet(array<string, string> $array): bool|Redis
Sets multiple key-value pairs in one atomic command.
MSETNX only returns TRUE if all the keys were set (see SETNX).
Sets multiple key-value pairs in one atomic command.
MSETNX only returns TRUE if all the keys were set (see SETNX).
Parameters
$array |
Pairs: array(key => value, ...)
|
Returns
TRUE in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
getMultiple(array $keys): array|Redis
Get the values of all the specified keys.
If one or more keys dont exist, the array will contain FALSE at the position of the key.
Get the values of all the specified keys.
If one or more keys dont exist, the array will contain FALSE at the position of the key.
Parameters
$keys |
Array containing the list of the keys
|
Returns
Array containing the values related to keys in argument or Redis if in multimode
Throws
|
#
|
public
|
mGet(array $array): false|list<false|string>|Redis
Returns the values of all specified keys. For every key that does not hold a string value or does not exist,
the special value false is returned. Because of this, the operation never fails.
Returns the values of all specified keys. For every key that does not hold a string value or does not exist,
the special value false is returned. Because of this, the operation never fails.
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
msetnx(array<string, string> $array): false|int|Redis
Set one ore more string keys but only if none of the key exist.
Set one ore more string keys but only if none of the key exist.
Returns
1 (if the keys were set) or 0 (no key was set) or Redis if in multimode
Throws
|
#
|
public
|
rPopLPush(string $srcKey, string $dstKey): string|mixed|false|Redis
Pops a value from the tail of a list, and pushes it to the front of another list.
Also return this value.
Pops a value from the tail of a list, and pushes it to the front of another list.
Also return this value.
Returns
The element that was moved in case of success, FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
bRPopLPush(string $srcKey, string $dstKey, int|float $timeout): string|mixed|bool|Redis
A blocking version of rPopLPush, with an integral timeout in the third parameter.
A blocking version of rPopLPush, with an integral timeout in the third parameter.
Parameters
$timeout |
The number of seconds to wait. Note that you must be connected to Redis >= 6.0.0 to send a floating point timeout.
|
Returns
The element that was moved in case of success, FALSE in case of timeout or Redis if in multimode
Throws
|
#
|
public
|
zAdd(string $key, array|float $score_or_options, mixed ...$more_scores_and_mems): false|int|Redis
Adds the specified member with a given score to the sorted set stored at key
Adds the specified member with a given score to the sorted set stored at key
Parameters
$key |
The sorted set in question.
|
$score_or_options |
Either the score for the first element, or an array of options.
'NX', # Only update elements that already exist
'NX', # Only add new elements but don't update existing ones.
'LT' # Only update existing elements if the new score is
# less than the existing one.
'GT' # Only update existing elements if the new score is
# greater than the existing one.
'CH' # Instead of returning the number of elements added,
# Redis will return the number Of elements that were
# changed in the operation.
'INCR' # Instead of setting each element to the provide score,
# increment the element by the
# provided score, much like ZINCRBY. When this option
# is passed, you may only send a single score and member.
|
...$more_scores_and_mems |
A variadic number of additional scores and members.
|
Returns
Number of values added or Redis if in multimode
Throws
|
#
|
public
|
zRange(string $key, string|int $start, string|int $end, array|bool|null $options = null): array|Redis
Returns a range of elements from the ordered set stored at the specified key,
with values in the range [start, end]. start and stop are interpreted as zero-based indices:
0 the first element,
1 the second ...
-1 the last element,
-2 the penultimate ...
Returns a range of elements from the ordered set stored at the specified key,
with values in the range [start, end]. start and stop are interpreted as zero-based indices:
0 the first element,
1 the second ...
-1 the last element,
-2 the penultimate ...
Parameters
$key |
The sorted set in question.
|
$start |
The starting index we want to return.
|
$end |
The final index we want to return.
|
$options |
This value may either be an array of options to pass to
the command, or for historical purposes a boolean which
controls just the 'WITHSCORES' option.
'WITHSCORES' => true, # Return both scores and members.
'LIMIT' => [10, 10], # Start at offset 10 and return 10 elements.
'REV' # Return the elements in reverse order
'BYSCORE', # Treat start and end as scores instead
'BYLEX' # Treat start and end as lexicographical values.
|
Returns
Array containing the values in specified range or Redis if in multimode
Throws
|
#
|
public
|
zRem(string $key, string|mixed $member1, string|mixed ...$otherMembers): false|int|Redis
Deletes a specified member from the ordered set.
Deletes a specified member from the ordered set.
Returns
Number of deleted values or Redis if in multimode
Throws
|
#
|
public
|
zDelete(string $key, string|mixed $member1, string|mixed ...$otherMembers): false|int|Redis
Returns
Number of deleted values or Redis if in multimode
Throws
|
#
|
public
|
zRevRange(string $key, int $start, int $end, mixed $scores = null): array|Redis
Returns the elements of the sorted set stored at the specified key in the range [start, end]
in reverse order. start and stop are interpretated as zero-based indices:
0 the first element,
1 the second ...
-1 the last element,
-2 the penultimate ...
Returns the elements of the sorted set stored at the specified key in the range [start, end]
in reverse order. start and stop are interpretated as zero-based indices:
0 the first element,
1 the second ...
-1 the last element,
-2 the penultimate ...
Parameters
$key |
The sorted set in question.
|
$start |
The index to start listing elements
|
$end |
The index to stop listing elements.
|
$scores |
Whether or not Redis should also return each members score.
|
Returns
Array containing the values in specified range or Redis if in multimode
Throws
|
#
|
public
|
zRangeByScore(string $key, string $start, string $end, array $options = []): array|false|Redis
Returns the elements of the sorted set stored at the specified key which have scores in the
range [start,end]. Adding a parenthesis before start or end excludes it from the range.
+inf and -inf are also valid limits. zRevRangeByScore returns the same items in reverse order, when the start and end parameters are swapped.
Returns the elements of the sorted set stored at the specified key which have scores in the
range [start,end]. Adding a parenthesis before start or end excludes it from the range.
+inf and -inf are also valid limits. zRevRangeByScore returns the same items in reverse order, when the start and end parameters are swapped.
Parameters
$key |
The sorted set to query.
|
$start |
The minimum score of elements that Redis should return.
|
$end |
The maximum score of elements that Redis should return.
|
$options |
Options that change how Redis will execute the command.
|
Returns
Array containing the values in specified range or Redis if in multimode
Throws
|
#
|
public
|
zRevRangeByScore(string $key, string $start, string $end, array $options = []): array|false|Redis
List elements from a Redis sorted set by score, highest to lowest
List elements from a Redis sorted set by score, highest to lowest
Parameters
$key |
The sorted set to query.
|
$start |
The highest score to include in the results.
|
$end |
The lowest score to include in the results.
|
$options |
An options array that modifies how the command executes.
$options = [
'WITHSCORES' => true|false # Whether or not to return scores
'LIMIT' => [offset, count] # Return a subset of the matching members
];
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
zRangeByLex(string $key, string $min, string $max, int $offset = -1, int $count = -1): array|false|Redis
Returns a lexigraphical range of members in a sorted set, assuming the members have the same score. The
min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values
'-' (negative inf) or '+' (positive inf). The command must be called with either three or five
arguments or will return FALSE.
Returns a lexigraphical range of members in a sorted set, assuming the members have the same score. The
min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values
'-' (negative inf) or '+' (positive inf). The command must be called with either three or five
arguments or will return FALSE.
Parameters
$key |
The ZSET you wish to run against.
|
$min |
The minimum alphanumeric value you wish to get.
|
$max |
The maximum alphanumeric value you wish to get.
|
$offset |
Optional argument if you wish to start somewhere other than the first element.
|
$count |
An optional count to limit the replies to (used in conjunction with offset)
|
Returns
Array containing the values in the specified range or Redis if in multimode
Throws
|
#
|
public
|
zMscore(string $key, mixed $member, mixed ...$other_members): Redis|array|false
Retrieve the score of one or more members in a sorted set.
Retrieve the score of one or more members in a sorted set.
Parameters
$key |
The sorted set
|
$member |
The first member to return the score from
|
...$other_members |
One or more additional members to return the scores of.
|
Returns
An array of the scores of the requested elements.
|
#
|
public
|
zPopMax(string $key, int|null $count = null): Redis|array|false
Pop one or more of the highest scoring elements from a sorted set.
Pop one or more of the highest scoring elements from a sorted set.
Parameters
$key |
The sorted set to pop elements from.
|
$count |
An optional count of elements to pop.
|
Returns
All of the popped elements with scores or false on fialure.
|
#
|
public
|
zPopMin(string $key, int|null $count = null): Redis|array|false
Pop one or more of the lowest scoring elements from a sorted set.
Pop one or more of the lowest scoring elements from a sorted set.
Parameters
$key |
The sorted set to pop elements from.
|
$count |
An optional count of elements to pop.
|
Returns
The popped elements with their scores or false on failure.
|
#
|
public
|
zRandMember(string $key, array|null $options = null): Redis|string|array
Retrieve one or more random members from a Redis sorted set.
Retrieve one or more random members from a Redis sorted set.
Parameters
$key |
The sorted set to pull random members from.
|
$options |
One or more options that determine exactly how the command operates.
|
Returns
One ore more random elements.
|
#
|
public
|
zRevRangeByLex(string $key, string $min, string $max, int $offset = -1, int $count = -1): false|array|Redis
List members of a Redis sorted set within a legographical range, in reverse order.
List members of a Redis sorted set within a legographical range, in reverse order.
Parameters
$key |
The sorted set to list
|
$min |
The minimum lexographical element to include in the result.
|
$offset |
An option offset within the matching elements to start at.
|
$count |
An optional count to limit the replies to.
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
zRemRangeByLex(string $key, string $min, string $max): int|false|Redis
Removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.
Applies when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.
Removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.
Applies when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.
Parameters
$key |
The sorted set to remove elements from.
|
$min |
The start of the lexographical range to remove.
|
$max |
The end of the lexographical range to remove
|
Returns
The number of elements removed
|
#
|
public
|
zCount(string $key, string $start, string $end): false|int|Redis
Returns the number of elements of the sorted set stored at the specified key which have
scores in the range [start,end]. Adding a parenthesis before start or end excludes it
from the range. +inf and -inf are also valid limits.
Returns the number of elements of the sorted set stored at the specified key which have
scores in the range [start,end]. Adding a parenthesis before start or end excludes it
from the range. +inf and -inf are also valid limits.
Returns
the size of a corresponding zRangeByScore or Redis if in multimode
Throws
|
#
|
public
|
zRemRangeByScore(string $key, string $start, string $end): false|int|Redis
Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end].
Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end].
Parameters
$start |
double or "+inf" or "-inf" as a string
|
$end |
double or "+inf" or "-inf" as a string
|
Returns
The number of values deleted from the sorted set or Redis if in multimode
Throws
|
#
|
public
|
zDeleteRangeByScore(string $key, float $start, float $end)
|
#
|
public
|
zRemRangeByRank(string $key, int $start, int $end): false|int|Redis
Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end].
Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end].
Returns
The number of values deleted from the sorted set or Redis if in multimode
Throws
|
#
|
public
|
zDeleteRangeByRank(string $key, int $start, int $end)
|
#
|
public
|
zCard(string $key): false|int|Redis
Returns the cardinality of an ordered set.
Returns the cardinality of an ordered set.
Returns
the set's cardinality or Redis if in multimode
Throws
|
#
|
public
|
zdiff(array $keys, array|null $options = null): Redis|array|false
Given one or more sorted set key names, return every element that is in the first
set but not any of the others.
Given one or more sorted set key names, return every element that is in the first
set but not any of the others.
Parameters
$keys |
One ore more sorted sets.
|
$options |
An array which can contain ['WITHSCORES' => true] if you want Redis to return members and scores.
|
Returns
An array of members or false on failure.
|
#
|
public
|
zSize(string $key): false|int|Redis
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
zScore(string $key, mixed $member): float|bool|Redis
Returns the score of a given member in the specified sorted set.
Returns the score of a given member in the specified sorted set.
Parameters
$key |
The sorted set to query.
|
$member |
The member we wish to query.
|
Returns
false if member or key not exists or Redis if in multimode
Throws
|
#
|
public
|
zRank(string $key, mixed $member): int|false|Redis
Returns the rank of a given member in the specified sorted set, starting at 0 for the item
with the smallest score. zRevRank starts at 0 for the item with the largest score.
Returns the rank of a given member in the specified sorted set, starting at 0 for the item
with the smallest score. zRevRank starts at 0 for the item with the largest score.
Returns
the item's score, or false if key or member is not exists or Redis if in multimode
Throws
|
#
|
public
|
zRevRank(string $key, string|mixed $member): int|false|Redis
Returns
the item's score, false - if key or member is not exists or Redis if in multimode
Throws
|
#
|
public
|
zIncrBy(string $key, float $value, mixed $member): float|Redis
Increments the score of a member from a sorted set by a given amount.
Increments the score of a member from a sorted set by a given amount.
Parameters
$value |
(double) value that will be added to the member's score
|
Returns
the new value or Redis if in multimode
Throws
|
#
|
public
|
zUnionStore(
string $output,
array $zSetKeys,
null|array $weights = null,
string|null $aggregateFunction = null,
): false|int|Redis
Creates an union of sorted sets given in second argument.
The result of the union will be stored in the sorted set defined by the first argument.
The third optionnel argument defines weights to apply to the sorted sets in input.
In this case, the weights will be multiplied by the score of each element in the sorted set
before applying the aggregation. The forth argument defines the AGGREGATE option which
specify how the results of the union are aggregated.
Creates an union of sorted sets given in second argument.
The result of the union will be stored in the sorted set defined by the first argument.
The third optionnel argument defines weights to apply to the sorted sets in input.
In this case, the weights will be multiplied by the score of each element in the sorted set
before applying the aggregation. The forth argument defines the AGGREGATE option which
specify how the results of the union are aggregated.
Parameters
$aggregateFunction |
Either "SUM", "MIN", or "MAX": defines the behaviour to use on
duplicate entries during the zUnionStore
|
Returns
The number of values in the new sorted set or Redis if in multimode
Throws
|
#
|
public
|
zUnion(string $Output, array $ZSetKeys, array|null $Weights = null, string $aggregateFunction = 'SUM')
|
#
|
public
|
zInterStore(
string $output,
array $zSetKeys,
null|array $weights = null,
string|null $aggregateFunction = null,
): false|int|Redis
Creates an intersection of sorted sets given in second argument.
The result of the union will be stored in the sorted set defined by the first argument.
The third optional argument defines weights to apply to the sorted sets in input.
In this case, the weights will be multiplied by the score of each element in the sorted set
before applying the aggregation. The forth argument defines the AGGREGATE option which
specify how the results of the union are aggregated.
Creates an intersection of sorted sets given in second argument.
The result of the union will be stored in the sorted set defined by the first argument.
The third optional argument defines weights to apply to the sorted sets in input.
In this case, the weights will be multiplied by the score of each element in the sorted set
before applying the aggregation. The forth argument defines the AGGREGATE option which
specify how the results of the union are aggregated.
Parameters
$aggregateFunction |
Either "SUM", "MIN", or "MAX":
defines the behaviour to use on duplicate entries during the zInterStore.
|
Returns
The number of values in the new sorted set or Redis if in multimode
Throws
|
#
|
public
|
zInter($Output, $ZSetKeys, array|null $Weights = null, string $aggregateFunction = 'SUM')
|
#
|
public
|
zScan(string $key, int|null &$iterator, string $pattern = null, int $count = 0): array|false|Redis
Scan a sorted set for members, with optional pattern and count
Scan a sorted set for members, with optional pattern and count
Parameters
$key |
String, the set to scan.
|
$iterator |
Long (reference), initialized to NULL.
|
$pattern |
String (optional), the pattern to match.
|
$count |
How many keys to return per iteration (Redis might return a different number).
|
Returns
PHPRedis will return matching keys from Redis, or FALSE when iteration is complete or Redis if in multimode
Throws
|
#
|
public
|
bzPopMax(string|array $key_or_keys, string|int|array $timeout_or_key, mixed ...$extra_args): false|array|Redis
Block until Redis can pop the highest or lowest scoring members from one or more ZSETs.
There are two commands (BZPOPMIN and BZPOPMAX for popping the lowest and highest scoring elements respectively.)
Block until Redis can pop the highest or lowest scoring members from one or more ZSETs.
There are two commands (BZPOPMIN and BZPOPMAX for popping the lowest and highest scoring elements respectively.)
Parameters
$key_or_keys |
Either a string key or an array of one or more keys.
|
$timeout_or_key |
If the previous argument was an array, this argument must be a timeout value. Otherwise it could also be another key.
|
...$extra_args |
Can consist of additional keys, until the last argument which needs to be a timeout.
|
Returns
Either an array with the key member and score of the highest or lowest element or an empty array or Redis if in multimode
if the timeout was reached without an element to pop.
Throws
|
#
|
public
|
bzPopMin(string|array $key_or_keys, string|int|array $timeout_or_key, mixed ...$extra_args): false|array|Redis
POP the minimum scoring element off of one or more sorted sets, blocking up to a specified timeout if no elements are available.
POP the minimum scoring element off of one or more sorted sets, blocking up to a specified timeout if no elements are available.
Parameters
$key_or_keys |
Either a string key or an array of one or more keys.
|
$timeout_or_key |
If the previous argument was an array, this argument must be a timeout value. Otherwise it could also be another key.
|
...$extra_args |
Can consist of additional keys, until the last argument which needs to be a timeout.
|
Returns
Either an array with the key member and score of the highest or lowest element or an empty array or Redis if in multimode
if the timeout was reached without an element to pop.
Throws
|
#
|
public
|
hSet(string $key, string $hashKey, mixed $value): int|bool|Redis
Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned.
Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned.
Returns
returns Redis if in multimode
- 1 if value didn't exist and was added successfully,
- 0 if the value was already present and was replaced, FALSE if there was an error.
Throws
|
#
|
public
|
hSetNx(string $key, string $hashKey, string $value): bool|Redis
Adds a value to the hash stored at key only if this field isn't already in the hash.
Adds a value to the hash stored at key only if this field isn't already in the hash.
Returns
TRUE if the field was set, FALSE if it was already present or Redis if in multimode
Throws
|
#
|
public
|
hGet(string $key, string $hashKey): string|false|Redis
Gets a value from the hash stored at key.
If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
Gets a value from the hash stored at key.
If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
Returns
The value, if the command executed successfully BOOL FALSE in case of failure or Redis if in multimode
Throws
|
#
|
public
|
hLen(string $key): int|false|Redis
Returns the length of a hash, in number of items
Returns the length of a hash, in number of items
Returns
the number of items in a hash, FALSE if the key doesn't exist or isn't a hash or Redis if in multimode
Throws
|
#
|
public
|
hDel(string $key, string $hashKey1, string ...$otherHashKeys): int|bool|Redis
Removes a values from the hash stored at key.
If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
Removes a values from the hash stored at key.
If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
Returns
Number of deleted fields or Redis if in multimode
Throws
|
#
|
public
|
hKeys(string $key): list<string>|false|Redis
Returns the keys in a hash, as an array of strings.
Returns the keys in a hash, as an array of strings.
Returns
An array of elements, the keys of the hash. This works like PHP's array_keys() or Redis if in multimode
Throws
|
#
|
public
|
hVals(string $key): list<mixed>|false|Redis
Returns the values in a hash, as an array of strings.
Returns the values in a hash, as an array of strings.
Returns
An array of elements, the values of the hash. This works like PHP's array_values() or Redis if in multimode
Throws
|
#
|
public
|
hGetAll(string $key): array<string, mixed>|false|Redis
Returns the whole hash, as an array of strings indexed by strings.
Returns the whole hash, as an array of strings indexed by strings.
Returns
An array of elements, the contents of the hash or Redis if in multimode
Throws
|
#
|
public
|
hExists(string $key, string $hashKey): bool|Redis
Verify if the specified member exists in a key.
Verify if the specified member exists in a key.
Returns
If the member exists in the hash table, return TRUE, otherwise return FALSE or Redis if in multimode
Throws
|
#
|
public
|
hIncrBy(string $key, string $hashKey, int $value): false|int|Redis
Increments the value of a member from a hash by a given amount.
Increments the value of a member from a hash by a given amount.
Parameters
$value |
(integer) value that will be added to the member's value
|
Returns
the new value or Redis if in multimode
Throws
|
#
|
public
|
hIncrByFloat(string $key, string $field, float $increment): float|false|Redis
Increment the float value of a hash field by the given amount
Increment the float value of a hash field by the given amount
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
hMSet(string $key, array $hashKeys): bool|Redis
Fills in a whole hash. Non-string values are converted to string, using the standard (string) cast.
NULL values are stored as empty strings
Fills in a whole hash. Non-string values are converted to string, using the standard (string) cast.
NULL values are stored as empty strings
Parameters
$hashKeys |
key → value array
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
hMGet(string $key, array $hashKeys): array|false|Redis
Retrieve the values associated to the specified fields in the hash.
Retrieve the values associated to the specified fields in the hash.
Returns
Array An array of elements, the values of the specified fields in the hash, or Redis if in multimode
with the hash keys as array keys.
Throws
|
#
|
public
|
hScan(string $key, &$iterator, string $pattern = null, int $count = 0): array|bool|Redis
Scan a HASH value for members, with an optional pattern and count.
Scan a HASH value for members, with an optional pattern and count.
Parameters
$pattern |
Optional pattern to match against.
|
$count |
How many keys to return in a go (only a sugestion to Redis).
|
Returns
An array of members that match our pattern or Redis if in multimode
Throws
|
#
|
public
|
hStrLen(string $key, string $field): false|int|Redis
Get the string length of the value associated with field in the hash stored at key
Get the string length of the value associated with field in the hash stored at key
Returns
the string length of the value associated with field, or zero when field is not present in the hash or Redis if in multimode
or key does not exist at all.
Throws
|
#
|
public
|
geoAdd(
string $key,
float $longitude,
float $latitude,
string $member,
mixed ...$other_triples_and_options,
): false|int|Redis
Add one or more geospatial items to the specified key.
This function must be called with at least one longitude, latitude, member triplet.
Add one or more geospatial items to the specified key.
This function must be called with at least one longitude, latitude, member triplet.
Parameters
...$other_triples_and_options |
You can continue to pass longitude, lattitude, and member arguments to add as many members
as you wish. Optionally, the final argument may be a string with options for the command
|
Returns
The number of elements added to the geospatial key or Redis if in multimode
Throws
|
#
|
public
|
geoHash(string $key, string ...$member): false|array|Redis
Retrieve Geohash strings for one or more elements of a geospatial index.
Retrieve Geohash strings for one or more elements of a geospatial index.
Parameters
...$member |
variadic list of members
|
Returns
One or more Redis Geohash encoded strings or Redis if in multimode
Throws
|
#
|
public
|
geoPos(string $key, string ...$member): array|Redis
Return longitude, latitude positions for each requested member.
Return longitude, latitude positions for each requested member.
Returns
One or more longitude/latitude positions or Redis if in multimode
Throws
|
#
|
public
|
geosearch(string $key, array|string $position, array|int|float $shape, string $unit, array $options = []): mixed[]
Search a geospacial sorted set for members in various ways.
Search a geospacial sorted set for members in various ways.
Parameters
$key |
The set to query.
|
$position |
Either a two element array with longitude and lattitude, or a string representing a member of the set.
|
$shape |
Either a number representine the radius of a circle to search, or
a two element array representing the width and height of a box to search.
|
$unit |
The unit of our shape. See geodist() for possible units.
|
$options |
See georadius() for options. Note that the STORE options are not allowed for this command.
|
|
#
|
public
|
geosearchstore(
string $dst,
string $src,
array|string $position,
array|int|float $shape,
string $unit,
array $options = [],
): mixed[]|int|true|Redis
Search a geospacial sorted set for members within a given area or range, storing the results into
a new set.
Search a geospacial sorted set for members within a given area or range, storing the results into
a new set.
Parameters
$dst |
The destination where results will be stored.
|
$src |
The key to query.
|
$position |
Either a two element array with longitude and lattitude, or a string representing a member of the set.
|
$shape |
Either a number representine the radius of a circle to search, or
a two element array representing the width and height of a box to search.
|
$unit |
The unit of our shape. See geoDist for possible units.
|
|
#
|
public
|
geoDist(string $key, string $member1, string $member2, string|null $unit = null): float|Redis
Return the distance between two members in a geospatial set. If units are passed it must be one of the following values:
- 'm' => Meters
- 'km' => Kilometers
- 'mi' => Miles
- 'ft' => Feet
Return the distance between two members in a geospatial set. If units are passed it must be one of the following values:
- 'm' => Meters
- 'km' => Kilometers
- 'mi' => Miles
- 'ft' => Feet
Parameters
$unit |
Which unit to use when computing distance, defaulting to meters. M - meters, KM - kilometers, FT - feet, MI - miles
|
Returns
The distance between the two passed members in the units requested (meters by default) or Redis if in multimode
Throws
|
#
|
public
|
geoRadius($key, $longitude, $latitude, $radius, $unit, array|null $options = []): mixed|Redis
Return members of a set with geospatial information that are within the radius specified by the caller.
Return members of a set with geospatial information that are within the radius specified by the caller.
Returns
When no STORE option is passed, this function returns an array of results or Redis if in multimode
If it is passed this function returns the number of stored entries.
Throws
|
#
|
public
|
geoRadiusByMember(string $key, string $member, $radius, $units, array|null $options = []): mixed|Redis
This method is identical to geoRadius except that instead of passing a longitude and latitude as the "source"
you pass an existing member in the geospatial set
This method is identical to geoRadius except that instead of passing a longitude and latitude as the "source"
you pass an existing member in the geospatial set
Parameters
Returns
The zero or more entries that are close enough to the member given the distance and radius specified or Redis if in multimode
Throws
|
#
|
public
|
config(string $operation, array|string|null $key_or_settings = null, string|null $value = null): mixed|Redis
Execute the Redis CONFIG command in a variety of ways.
Execute the Redis CONFIG command in a variety of ways.
Parameters
$operation |
Operations that PhpRedis supports: RESETSTAT, REWRITE, GET, and SET.
|
$key_or_settings |
One or more keys or values.
|
$value |
The value if this is a CONFIG SET operation.
|
Returns
Associative array for GET , key -> value or Redis if in multimode
Throws
|
#
|
public
|
eval(string $script, array $args = [], int $numKeys = 0): mixed|Redis
Evaluate a LUA script serverside
Evaluate a LUA script serverside
Returns
What is returned depends on what the LUA script itself returns, which could be a scalar value or Redis if in multimode
(int/string), or an array. Arrays that are returned can also contain other arrays, if that's how it was set up in
your LUA script. If there is an error executing the LUA script, the getLastError() function can tell you the
message that came back from Redis (e.g. compile error).
Throws
|
#
|
public
|
evaluate(string $script, array $args = [], int $numKeys = 0): mixed|Redis
Returns
@see eval() , returns Redis if in multimode
Throws
|
#
|
public
|
evalSha(string $scriptSha, array $args = [], int $numKeys = 0): mixed|Redis
Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself.
In order to run this command Redis will have to have already loaded the script, either by running it or via
the SCRIPT LOAD command.
Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself.
In order to run this command Redis will have to have already loaded the script, either by running it or via
the SCRIPT LOAD command.
Returns
@see eval() , returns Redis if in multimode
Throws
|
#
|
public
|
evaluateSha(string $scriptSha, array $args = [], int $numKeys = 0)
|
#
|
public
|
script(string $command, mixed ...$script): mixed|Redis
Execute the Redis SCRIPT command to perform various operations on the scripting subsystem.
Execute the Redis SCRIPT command to perform various operations on the scripting subsystem.
Parameters
$command |
load | flush | kill | exists
|
Returns
This command returns various things depending on the specific operation executed. Redis if in multimode
Throws
|
#
|
public
|
getLastError(): string|null
The last error message (if any)
The last error message (if any)
Returns
A string with the last returned script based error message, or NULL if there is no error
Throws
|
#
|
public
|
clearLastError(): bool
Clear the last error message
Clear the last error message
Returns
This should always return true or throw an exception if we're not connected.
Throws
|
#
|
public
|
client(string $command, mixed ...$args): mixed
Issue the CLIENT command with various arguments.
The Redis CLIENT command can be used in four ways:
- CLIENT LIST
- CLIENT GETNAME
- CLIENT SETNAME [name]
- CLIENT KILL [ip:port]
Issue the CLIENT command with various arguments.
The Redis CLIENT command can be used in four ways:
- CLIENT LIST
- CLIENT GETNAME
- CLIENT SETNAME [name]
- CLIENT KILL [ip:port]
Returns
This will vary depending on which client command was executed:
- CLIENT LIST will return an array of arrays with client information.
- CLIENT GETNAME will return the client name or false if none has been set
- CLIENT SETNAME will return true if it can be set and false if not
- CLIENT KILL will return true if the client can be killed, and false if not
Throws
|
#
|
public
|
_prefix(string $value): string
A utility method to prefix the value with the prefix setting for phpredis.
A utility method to prefix the value with the prefix setting for phpredis.
Parameters
$value |
The value you wish to prefix
|
Returns
If a prefix is set up, the value now prefixed
If there is no prefix, the value will be returned unchanged.
Throws
|
#
|
public
|
_unserialize(string $value): mixed
A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the
value will be returned unchanged. If there is a serializer set up, and the data passed in is malformed, an
exception will be thrown. This can be useful if phpredis is serializing values, and you return something from
redis in a LUA script that is serialized.
A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the
value will be returned unchanged. If there is a serializer set up, and the data passed in is malformed, an
exception will be thrown. This can be useful if phpredis is serializing values, and you return something from
redis in a LUA script that is serialized.
Parameters
$value |
The value to be unserialized
|
|
#
|
public
|
_serialize(mixed $value): string
A utility method to serialize values manually. This method allows you to serialize a value with whatever
serializer is configured, manually. This can be useful for serialization/unserialization of data going in
and out of EVAL commands as phpredis can't automatically do this itself. Note that if no serializer is
set, phpredis will change Array values to 'Array', and Objects to 'Object'.
A utility method to serialize values manually. This method allows you to serialize a value with whatever
serializer is configured, manually. This can be useful for serialization/unserialization of data going in
and out of EVAL commands as phpredis can't automatically do this itself. Note that if no serializer is
set, phpredis will change Array values to 'Array', and Objects to 'Object'.
Parameters
$value |
The value to be serialized.
|
|
#
|
public
|
dump(string $key): string|false|Redis
Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command.
The data that comes out of DUMP is a binary representation of the key as Redis stores it.
Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command.
The data that comes out of DUMP is a binary representation of the key as Redis stores it.
Returns
A binary string representing the key's value or FALSE if the key doesn't exist or Redis if in multimode
Throws
|
#
|
public
|
restore(string $key, int $ttl, string $value, array|null $options = null): bool|Redis
Restore a key from the result of a DUMP operation.
Restore a key from the result of a DUMP operation.
Parameters
$key |
The name of the key you wish to create.
|
$ttl |
What Redis should set the key's TTL (in milliseconds) to once it is created.Zero means no TTL at all.
|
$value |
The serialized binary value of the string (generated by DUMP).
|
$options |
An array of additional options that modifies how the command operates.
$options = [
'ABSTTL' # If this is present, the $ttl provided by the user should
# be an absolute timestamp, in milliseconds()
|
Returns
True if the key was stored, false if not.
Throws
|
#
|
public
|
migrate(
string $host,
int $port,
string|array $key,
$dstdb,
int $timeout,
bool $copy = false,
bool $replace = false,
mixed $credentials = null,
): bool|Redis
Migrates a key to a different Redis instance.
Migrates a key to a different Redis instance.
Parameters
$host |
The destination host
|
$port |
The TCP port to connect to.
|
$key |
The key to migrate.
|
$timeout |
The maximum amount of time given to this transfer.
|
$copy |
Should we send the COPY flag to redis.
|
$replace |
Should we send the REPLACE flag to redis.
|
Throws
|
#
|
public
|
time(): false|array
Retrieve the server time from the connected Redis instance.
Retrieve the server time from the connected Redis instance.
Returns
If successful, the time will come back as an associative array with element zero being the
unix timestamp, and element one being microseconds.
Throws
|
#
|
public
|
scan(&$iterator, string $pattern = null, int $count = 0, string|null $type = null): array|false|Redis
Scan the keyspace for keys
Scan the keyspace for keys
Parameters
$pattern |
An optional glob-style pattern for matching key names. If passed as
NULL, it is the equivalent of sending '*' (match every key).
|
$count |
A hint to redis that tells it how many keys to return in a single
call to SCAN. The larger the number, the longer Redis may block
clients while iterating the key space.
|
$type |
An optional argument to specify which key types to scan (e.g. 'STRING', 'LIST', 'SET')
|
Returns
This function will return an array of keys or FALSE if there are no more keys or Redis if in multimode
Throws
|
#
|
public
|
pfAdd(string $key, array $elements): bool|int|Redis
Adds all the element arguments to the HyperLogLog data structure stored at the key.
Adds all the element arguments to the HyperLogLog data structure stored at the key.
Returns
Returns 1 if the set was altered, and zero if not. Redis if in multimode
Throws
|
#
|
public
|
pfCount(string|array $key_or_keys): false|int|Redis
When called with a single key, returns the approximated cardinality computed by the HyperLogLog data
structure stored at the specified variable, which is 0 if the variable does not exist.
When called with a single key, returns the approximated cardinality computed by the HyperLogLog data
structure stored at the specified variable, which is 0 if the variable does not exist.
Parameters
$key_or_keys |
Either one key or an array of keys
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
pfMerge(string $destKey, array $sourceKeys): bool|Redis
Merge multiple HyperLogLog values into an unique value that will approximate the cardinality
of the union of the observed Sets of the source HyperLogLog structures.
Merge multiple HyperLogLog values into an unique value that will approximate the cardinality
of the union of the observed Sets of the source HyperLogLog structures.
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
rawCommand(string $command, mixed ...$arguments): mixed|Redis
Send arbitrary things to the redis server.
Send arbitrary things to the redis server.
Parameters
$command |
Required command to send to the server.
|
...$arguments |
Optional variable amount of arguments to send to the server.
|
Returns
returns Redis if in multimode
Throws
|
#
|
public
|
getMode(): false|int|Redis
Detect whether we're in ATOMIC/MULTI/PIPELINE mode.
Detect whether we're in ATOMIC/MULTI/PIPELINE mode.
Returns
Either Redis::ATOMIC, Redis::MULTI or Redis::PIPELINE or Redis if in multimode
Throws
|
#
|
public
|
xAck(string $stream, string $group, array $messages): false|int|Redis
Acknowledge one or more messages on behalf of a consumer group.
Acknowledge one or more messages on behalf of a consumer group.
Returns
The number of messages Redis reports as acknowledged or Redis if in multimode
Throws
|
#
|
public
|
xAdd(
string $key,
string $id,
array $messages,
$maxLen = 0,
bool $isApproximate = false,
bool $nomkstream = false,
): string|true|Redis
Append a message to a stream.
Append a message to a stream.
Parameters
$id |
The ID for the message we want to add. This can be the special value ''
which means Redis will generate the ID that appends the message to the
end of the stream. It can also be a value in the form - which will
generate an ID that appends to the end ot entries with the same value (if any exist).
|
$isApproximate |
Used in conjunction with $maxlen , this flag tells Redis to trim the stream
but in a more efficient way, meaning the trimming may not be exactly to $maxlen values.
|
$nomkstream |
If passed as TRUE , the stream must exist for Redis to append the message.
|
Returns
The added message ID or Redis if in multimode
Throws
|
#
|
public
|
xClaim(string $key, string $group, string $consumer, int $min_iddle, array $ids, array $options): false|array|Redis
This method allows a consumer to take ownership of pending stream entries, by ID. Another
command that does much the same thing but does not require passing specific IDs is Redis::xAutoClaim .
This method allows a consumer to take ownership of pending stream entries, by ID. Another
command that does much the same thing but does not require passing specific IDs is Redis::xAutoClaim .
Parameters
$key |
The stream we wish to claim messages for.
|
$group |
Our consumer group.
|
$consumer |
Our consumer.
|
$options |
An options array that modifies how the command operates.
|
Returns
Either an array of message IDs along with corresponding data, or just an array of IDs or Redis if in multimode
(if the 'JUSTID' option was passed).
Throws
|
#
|
public
|
xDel(string $key, array $ids): false|int|Redis
Delete one or more messages from a stream
Delete one or more messages from a stream
Returns
The number of messages removed or Redis if in multimode
Throws
|
#
|
public
|
xGroup(
string $operation,
string|null $key = null,
string|null $group = null,
string|null $id_or_consumer = null,
bool $mkstream = false,
int $entries_read = -2,
): mixed|Redis
Perform various operation on consumer groups for a particular Redis STREAM. What the command does
is primarily based on which operation is passed.
Perform various operation on consumer groups for a particular Redis STREAM. What the command does
is primarily based on which operation is passed.
Parameters
$operation |
The subcommand you intend to execute. Valid options are as follows
'HELP' - Redis will return information about the command
Requires: none
'CREATE' - Create a consumer group.
Requires: Key, group, consumer.
'SETID' - Set the ID of an existing consumer group for the stream.
Requires: Key, group, id.
'CREATECONSUMER' - Create a new consumer group for the stream. You must
also pass key, group, and the consumer name you wish to
create.
Requires: Key, group, consumer.
'DELCONSUMER' - Delete a consumer from group attached to the stream.
Requires: Key, group, consumer.
'DESTROY' - Delete a consumer group from a stream.
Requires: Key, group.
|
$key |
The STREAM we're operating on.
|
$group |
The consumer group we want to create/modify/delete.
|
$id_or_consumer |
The STREAM id (e.g. '$') or consumer group. See the operation section
for information about which to send.
|
$mkstream |
This flag may be sent in combination with the 'CREATE' operation, and
cause Redis to also create the STREAM if it doesn't currently exist.
|
$entries_read |
Allows you to set Redis' 'entries-read' STREAM value. This argument is
only relevant to the 'CREATE' and 'SETID' operations.
Note: Requires Redis >= 7.0.0.
|
Returns
This command returns different types depending on the specific XGROUP command executed or Redis if in multimode
Throws
|
#
|
public
|
xInfo(string $operation, string|null $arg1 = null, string|null $arg2 = null, int $count = -1): mixed|Redis
Get information about a stream or consumer groups
Get information about a stream or consumer groups
Parameters
$operation |
The specific info operation to perform. e.g.: 'CONSUMERS', 'GROUPS', 'STREAM', 'HELP'
|
$arg1 |
The first argument (depends on operation)
|
$arg2 |
The second argument
|
$count |
The COUNT argument to XINFO STREAM
|
Returns
This command returns different types depending on which subcommand is used or Redis if in multimode
Throws
|
#
|
public
|
xLen(string $stream): false|int|Redis
Get the length of a given stream.
Get the length of a given stream.
Returns
The number of messages in the stream or Redis if in multimode
Throws
|
#
|
public
|
xPending(
string $stream,
string $group,
string|null $start = null,
string|null $end = null,
int $count = -1,
string|null $consumer = null,
): array|string|false|Redis
Get information about pending messages in a given stream
Get information about pending messages in a given stream
Parameters
$stream |
The stream to inspect.
|
$group |
The user group we want to see pending messages from.
|
$start |
The minimum ID to consider.
|
$end |
The maximum ID to consider.
|
$count |
Optional maximum number of messages to return.
|
$consumer |
If provided, limit the returned messages to a specific consumer.
|
Returns
Information about the pending messages, in various forms depending on or Redis if in multimode
the specific invocation of XPENDING.
Throws
|
#
|
public
|
xRange(string $stream, string $start, string $end, int $count = -1): array|bool|Redis
Get a range of messages from a given stream
Get a range of messages from a given stream
Parameters
$stream |
The stream key name to list.
|
$start |
The minimum ID to return.
|
$end |
The maximum ID to return.
|
$count |
An optional maximum number of entries to return.
|
Returns
The messages in the stream within the requested range or Redis if in multimode
Throws
|
#
|
public
|
xRead(array $streams, int $count = -1, int $block = -1): array|bool|Redis
Read data from one or more streams and only return IDs greater than sent in the command.
Read data from one or more streams and only return IDs greater than sent in the command.
Parameters
$streams |
An associative array with stream name keys and minimum id values.
|
$count |
An optional limit to how many entries are returnd per stream
|
$block |
An optional maximum number of milliseconds to block the caller if no data is available on any of the provided streams.
|
Returns
The messages in the stream newer than the IDs passed to Redis (if any) or Redis if in multimode
Throws
|
#
|
public
|
xReadGroup(string $group, string $consumer, array $streams, int|null $count = 1, int|null $block = 1): array|bool|Redis
This method is similar to xRead except that it supports reading messages for a specific consumer group.
This method is similar to xRead except that it supports reading messages for a specific consumer group.
Parameters
$group |
The consumer group to use.
|
$consumer |
The consumer to use.
|
$streams |
An array of stream names and message IDs
|
$count |
Optional maximum number of messages to return
|
$block |
How long to block if there are no messages available.
|
Returns
The messages delivered to this consumer group (if any) or Redis if in multimode
Throws
|
#
|
public
|
xRevRange(string $stream, string $end, string $start, int $count = -1): array|bool|Redis
This is identical to xRange except the results come back in reverse order.
Also note that Redis reverses the order of "start" and "end".
This is identical to xRange except the results come back in reverse order.
Also note that Redis reverses the order of "start" and "end".
Parameters
$stream |
The stream key to query.
|
$end |
The maximum message ID to include.
|
$start |
The minimum message ID to include.
|
$count |
An optional maximum number of messages to include.
|
Returns
The messages in the range specified or Redis if in multimode
Throws
|
#
|
public
|
xtrim(string $key, string $threshold, bool $approx = false, bool $minid = false, int $limit = -1): Redis|int|false
Truncate a STREAM key in various ways.
Truncate a STREAM key in various ways.
Parameters
$key |
The STREAM key to trim.
|
$threshold |
This can either be a maximum length, or a minimum id.
MAXLEN - An integer describing the maximum desired length of the stream after the command.
MINID - An ID that will become the new minimum ID in the stream, as Redis will trim all
messages older than this ID.
|
$approx |
Whether redis is allowed to do an approximate trimming of the stream. This is
more efficient for Redis given how streams are stored internally.
|
$minid |
When set to true , users should pass a minimum ID to the $threshold argument.
|
$limit |
An optional upper bound on how many entries to trim during the command.
|
Returns
The number of entries deleted from the stream.
|
#
|
public
|
sAddArray(string $key, array $values): int|bool|Redis
Adds a values to the set value stored at key.
Adds a values to the set value stored at key.
Parameters
$key |
Required key
|
$values |
Required values
|
Returns
The number of elements added to the set or Redis if in multimode
If this value is already in the set, FALSE is returned
Throws
|
#
|
public
|
__destruct()
|
#
|
public
|
_compress(string $value): string
Compress a value with the currently configured compressor as set with Redis::setOption().
Compress a value with the currently configured compressor as set with Redis::setOption().
Parameters
$value |
The value to be compressed
|
Returns
|
#
|
public
|
_uncompress(string $value): string
Uncompress the provided argument that has been compressed with the
currently configured compressor as set with Redis::setOption().
Uncompress the provided argument that has been compressed with the
currently configured compressor as set with Redis::setOption().
Parameters
$value |
The compressed value to uncompress.
|
Returns
|
#
|
public
|
_pack(mixed $value): string
Pack the provided value with the configured serializer and compressor as set with Redis::setOption().
Pack the provided value with the configured serializer and compressor as set with Redis::setOption().
Parameters
Returns
The packed result having been serialized and compressed.
|
#
|
public
|
_unpack(string $value): mixed
Unpack the provided value with the configured compressor and serializer as set with Redis::setOption().
Unpack the provided value with the configured compressor and serializer as set with Redis::setOption().
Parameters
$value |
The value which has been serialized and compressed.
|
Returns
The uncompressed and eserialized value.
|
#
|
public
|
acl(string $subcmd, string ...$args): mixed
Execute the Redis ACL command.
Execute the Redis ACL command.
Parameters
$subcmd |
Minumum of one argument for Redis and two for RedisCluster.
|
|
#
|
public
|
bzmpop(float $timeout, array $keys, string $from, int $count = 1): array|null|false|Redis
POP one or more elements from one or more sorted sets, blocking up to a specified amount of time when no elements are available.
POP one or more elements from one or more sorted sets, blocking up to a specified amount of time when no elements are available.
Parameters
$timeout |
How long to block if there are no element available
|
$keys |
The sorted sets to pop from
|
$from |
The string 'MIN' or 'MAX' (case insensitive) telling Redis whether you wish to pop the lowest or highest scoring members from the set(s).
|
$count |
Pop up to how many elements.
|
Returns
This function will return an array of popped elements, or false
depending on whether any elements could be popped within the specified timeout.
|
#
|
public
|
zmpop(array $keys, string $from, int $count = 1): array|null|false|Redis
POP one or more of the highest or lowest scoring elements from one or more sorted sets.
POP one or more of the highest or lowest scoring elements from one or more sorted sets.
Parameters
$keys |
One or more sorted sets
|
$from |
The string 'MIN' or 'MAX' (case insensitive) telling Redis whether you want to pop the lowest or highest scoring elements.
|
$count |
Pop up to how many elements at once.
|
Returns
An array of popped elements or false if none could be popped.
|
#
|
public
|
blmpop(float $timeout, array $keys, string $from, int $count = 1): array|null|false|Redis
Pop one or more elements from one or more Redis LISTs, blocking up to a specified timeout when no elements are available.
Pop one or more elements from one or more Redis LISTs, blocking up to a specified timeout when no elements are available.
Parameters
$timeout |
The number of seconds Redis will block when no elements are available.
|
$keys |
One or more Redis LISTs to pop from.
|
$from |
The string 'LEFT' or 'RIGHT' (case insensitive), telling Redis whether to pop elements from the beginning or end of the LISTs.
|
$count |
Pop up to how many elements at once.
|
Returns
One or more elements popped from the list(s) or false if all LISTs were empty.
|
#
|
public
|
lmpop(array $keys, string $from, int $count = 1): array|null|false|Redis
Pop one or more elements off of one or more Redis LISTs.
Pop one or more elements off of one or more Redis LISTs.
Parameters
$keys |
An array with one or more Redis LIST key names.
|
$from |
The string 'LEFT' or 'RIGHT' (case insensitive), telling Redis whether to pop elements from the beginning or end of the LISTs.
|
$count |
The maximum number of elements to pop at once.
|
Returns
One or more elements popped from the LIST(s) or false if all the LISTs were empty.
|
#
|
public
|
command(string|null $opt = null, mixed ...$args): mixed
|
#
|
public
|
copy(string $src, string $dst, array|null $options = null): bool|Redis
Make a copy of a key. $redis = new Redis(['host' => 'localhost']);
Make a copy of a key. $redis = new Redis(['host' => 'localhost']);
Parameters
$src |
The key to copy
|
$dst |
The name of the new key created from the source key.
|
$options |
An array with modifiers on how COPY should operate.
'REPLACE' => true|false # Whether to replace an existing key.
'DB' => int # Copy key to specific db.
|
Returns
True if the copy was completed and false if not.
|
#
|
public
|
debug(string $key): string|Redis
|
#
|
public
|
eval_ro(string $script_sha, mixed[] $args = [], int $num_keys = 0): mixed
This is simply the read-only variant of eval, meaning the underlying script may not modify data in redis.
This is simply the read-only variant of eval, meaning the underlying script may not modify data in redis.
|
#
|
public
|
evalsha_ro(string $sha1, mixed[] $args = [], int $num_keys = 0): mixed
This is simply the read-only variant of evalsha, meaning the underlying script may not modify data in redis.
This is simply the read-only variant of evalsha, meaning the underlying script may not modify data in redis.
|
#
|
public
|
failover(array|null $to = null, bool $abort = false, int $timeout = 0): bool|Redis
|
#
|
public
|
expiretime(string $key): int|false|Redis
Get the expiration of a given key as a unix timestamp
Get the expiration of a given key as a unix timestamp
Parameters
Returns
The timestamp when the key expires, or -1 if the key has no expiry and -2 if the key doesn't exist.
|
#
|
public
|
pexpiretime(string $key): int|false|Redis
Get the expriation timestamp of a given Redis key but in milliseconds.
Get the expriation timestamp of a given Redis key but in milliseconds.
Parameters
Returns
The expiration timestamp of this key (in milliseconds) or -1 if the key has no expiration, and -2 if it does not exist.
|
#
|
public
|
fcall(string $fn, array $keys = [], array $args = []): mixed
Parameters
$fn |
The name of the function
|
$keys |
Optional list of keys
|
$args |
Optional list of args
|
Returns
Function may return arbitrary data so this method can return strings, arrays, nested arrays, etc.
|
#
|
public
|
fcall_ro(string $fn, array $keys = [], array $args = []): mixed
This is a read-only variant of the FCALL command that cannot execute commands that modify data.
This is a read-only variant of the FCALL command that cannot execute commands that modify data.
Parameters
$fn |
The name of the function
|
$keys |
Optional list of keys
|
$args |
Optional list of args
|
Returns
Function may return arbitrary data so this method can return strings, arrays, nested arrays, etc.
|
#
|
public
|
function(string $operation, mixed ...$args): Redis|bool|string|array
Functions is an API for managing code to be executed on the server.
Functions is an API for managing code to be executed on the server.
Parameters
$operation |
The subcommand you intend to execute. Valid options are as follows
'LOAD' - Create a new library with the given library name and code.
'DELETE' - Delete the given library.
'LIST' - Return general information on all the libraries
'STATS' - Return information about the current function running
'KILL' - Kill the current running function
'FLUSH' - Delete all the libraries
'DUMP' - Return a serialized payload representing the current libraries
'RESTORE' - Restore the libraries represented by the given payload
|
...$args |
Additional arguments
|
Returns
|
#
|
public
|
georadius_ro(string $key, float $lng, float $lat, float $radius, string $unit, mixed[] $options = []): mixed
A readonly variant of GEORADIUS that may be executed on replicas.
A readonly variant of GEORADIUS that may be executed on replicas.
|
#
|
public
|
georadiusbymember_ro(string $key, string $member, float $radius, string $unit, mixed[] $options = []): mixed
This is the read-only variant of GEORADIUSBYMEMBER that can be run on replicas.
This is the read-only variant of GEORADIUSBYMEMBER that can be run on replicas.
|
#
|
public
|
getEx(string $key, array $options = []): string|bool|Redis
Get the value of a key and optionally set it's expiration.
Get the value of a key and optionally set it's expiration.
Parameters
$key |
The key to query
|
$options |
Options to modify how the command works.
'EX' => # Expire in N seconds
'PX' => # Expire in N milliseconds
'EXAT' => # Expire at a unix timestamp (in seconds)
'PXAT' => # Expire at a unix timestamp (in milliseconds);
'PERSIST' # Remove any configured expiration on the key.
|
Returns
The key's value or false if it didn't exist.
|
#
|
public
|
getDel(string $key): Redis|string|bool
Get a key from Redis and delete it in an atomic operation.
Get a key from Redis and delete it in an atomic operation.
Parameters
$key |
The key to get/delete.
|
Returns
The value of the key or false if it didn't exist.
|
#
|
public
|
lcs(string $key1, string $key2, array|null $options = null): Redis|string|array|int|false
Get the longest common subsequence between two string keys.
Get the longest common subsequence between two string keys.
Parameters
$key1 |
The first key to check
|
$key2 |
The second key to check
|
$options |
An optional array of modifiers for the comand.
'MINMATCHLEN' => int # Exclude matching substrings that are less than this value
'WITHMATCHLEN' => bool # Whether each match should also include its length.
'LEN' # Return the length of the longest subsequence
'IDX' # Each returned match will include the indexes where the
# match occurs in each string.
NOTE: 'LEN' cannot be used with 'IDX'.
|
Returns
Various reply types depending on options.
|
#
|
public
|
getTransferredBytes(): array
Get the number of bytes sent and received on the socket.
Get the number of bytes sent and received on the socket.
Returns
An array in the form [$sent_bytes, $received_bytes]
|
#
|
public
|
clearTransferredBytes(): void
Reset the number of bytes sent and received on the socket.
Reset the number of bytes sent and received on the socket.
|
#
|
public
|
hRandField(string $key, array|null $options = null): Redis|array|string
Get one or more random field from a hash.
Get one or more random field from a hash.
Parameters
$key |
The hash to query.
|
$options |
An array of options to modify how the command behaves.
'COUNT' => int # An optional number of fields to return.
'WITHVALUES' => bool # Also return the field values.
|
Returns
One or more random fields (and possibly values).
|
#
|
public
|
lMove(string $src, string $dst, string $wherefrom, string $whereto): Redis|string|false
Move an element from one list into another.
Move an element from one list into another.
Parameters
$src |
The source list.
|
$dst |
The destination list
|
$wherefrom |
Where in the source list to retrieve the element. This can be either
- Redis::LEFT , or Redis::RIGHT .
|
$whereto |
Where in the destination list to put the element. This can be either
- Redis::LEFT , or Redis::RIGHT .
|
Returns
The element removed from the source list.
|
#
|
public
|
blmove(string $src, string $dst, string $wherefrom, string $whereto, float $timeout)
Move an element from one list to another, blocking up to a timeout until an element is available.
Move an element from one list to another, blocking up to a timeout until an element is available.
Parameters
$src |
The source list
|
$dst |
The destination list
|
$wherefrom |
Where in the source list to extract the element. - Redis::LEFT , or Redis::RIGHT .
|
$whereto |
Where in the destination list to put the element.- Redis::LEFT , or Redis::RIGHT .
|
$timeout |
How long to block for an element.
|
|
#
|
public
|
lPos(string $key, mixed $value, array|null $options = null): Redis|null|bool|int|array
Retrieve the index of an element in a list.
Retrieve the index of an element in a list.
Parameters
$key |
The list to query.
|
$value |
The value to search for.
|
$options |
Options to configure how the command operates
# How many matches to return. By default a single match is returned.
# If count is set to zero, it means unlimited.
'COUNT' =>
|
Returns
Returns one or more of the matching indexes, or null/false if none were found.
|
#
|
public
|
reset(): Redis|bool
Reset the state of the connection.
Reset the state of the connection.
Returns
Should always return true unless there is an error.
|
#
|
public
|
sInterCard(array $keys, int $limit = -1): Redis|int|false
Compute the intersection of one or more sets and return the cardinality of the result.
Compute the intersection of one or more sets and return the cardinality of the result.
Parameters
$keys |
One or more set key names.
|
$limit |
A maximum cardinality to return. This is useful to put an upper bound on the amount of work Redis will do.
|
|
#
|
public
|
replicaof(string|null $host = null, int $port = 6379): Redis|bool
Used to turn a Redis instance into a replica of another, or to remove
replica status promoting the instance to a primary.
Used to turn a Redis instance into a replica of another, or to remove
replica status promoting the instance to a primary.
Parameters
$host |
The host of the primary to start replicating.
|
$port |
The port of the primary to start replicating.
|
Returns
Success if we were successfully able to start replicating a primary or
were able to promote teh replicat to a primary.
|
#
|
public
|
touch(array|string $key_or_array, string ...$more_keys): Redis|int|false
Update one or more keys last modified metadata.
Update one or more keys last modified metadata.
Parameters
$key_or_array |
Either the first key or if passed as the only argument an array of keys.
|
...$more_keys |
One or more keys to send to the command.
|
Returns
This command returns the number of keys that exist and had their last modified time reset
|
#
|
public
|
sort_ro(string $key, mixed[]|null $options = null): mixed
This is simply a read-only variant of the sort command
This is simply a read-only variant of the sort command
|
#
|
public
|
ssubscribe(array $channels, callable $cb): bool
Subscribes the client to the specified shard channels.
Subscribes the client to the specified shard channels.
Parameters
$channels |
One or more channel names.
|
$cb |
The callback PhpRedis will invoke when we receive a message from one of the subscribed channels.
|
Returns
True on success, false on faiilure. Note that this command will block the
client in a subscribe loop, waiting for messages to arrive.
|
#
|
public
|
sunsubscribe(array $channels): Redis|array|bool
Unsubscribes the client from the given shard channels,
or from all of them if none is given.
Unsubscribes the client from the given shard channels,
or from all of them if none is given.
Parameters
$channels |
One or more channels to unsubscribe from.
|
Returns
The array of unsubscribed channels.
|
#
|
public
|
xAutoClaim(
string $key,
string $group,
string $consumer,
int $min_idle,
string $start,
int $count = -1,
bool $justid = false,
): Redis|array|bool
This command allows a consumer to claim pending messages that have been idle for a specified period of time.
Its purpose is to provide a mechanism for picking up messages that may have had a failed consumer.
This command allows a consumer to claim pending messages that have been idle for a specified period of time.
Its purpose is to provide a mechanism for picking up messages that may have had a failed consumer.
Parameters
$key |
The stream to check.
|
$group |
The consumer group to query.
|
$consumer |
Which consumer to check.
|
$min_idle |
The minimum time in milliseconds for the message to have been pending.
|
$start |
The minimum message id to check.
|
$count |
An optional limit on how many messages are returned.
|
$justid |
If the client only wants message IDs and not all of their data.
|
Returns
An array of pending IDs or false if there are none, or on failure.
|
#
|
public
|
zLexCount(string $key, string $min, string $max): Redis|int|false
Count the number of elements in a sorted set whos members fall within the provided
lexographical range.
Count the number of elements in a sorted set whos members fall within the provided
lexographical range.
Parameters
$key |
The sorted set to check.
|
$min |
The minimum matching lexographical string
|
$max |
The maximum matching lexographical string
|
Returns
The number of members that fall within the range or false on failure.
|
#
|
public
|
zRangeStore(
string $dstkey,
string $srckey,
string $start,
string $end,
array|bool|null $options = null,
): Redis|int|false
This command is similar to ZRANGE except that instead of returning the values directly
it will store them in a destination key provided by the user
This command is similar to ZRANGE except that instead of returning the values directly
it will store them in a destination key provided by the user
Parameters
$dstkey |
The key to store the resulting element(s)
|
$srckey |
The source key with element(s) to retrieve
|
$start |
The starting index to store
|
$end |
The ending index to store
|
$options |
Our options array that controls how the command will function.
|
Returns
The number of elements stored in $dstkey or false on failure.
|
#
|
public
|
zDiffStore(string $dst, array $keys): Redis|int|false
Store the difference of one or more sorted sets in a destination sorted set.
Store the difference of one or more sorted sets in a destination sorted set.
Parameters
$dst |
The destination set name.
|
$keys |
One or more source key names
|
Returns
The number of elements stored in the destination set or false on failure.
|
#
|
public
|
zInterCard(array $keys, int $limit = -1): Redis|int|false
Similar to ZINTER but instead of returning the intersected values, this command returns the
cardinality of the intersected set.
Similar to ZINTER but instead of returning the intersected values, this command returns the
cardinality of the intersected set.
Parameters
$keys |
One ore more sorted set key names.
|
$limit |
An optional upper bound on the returned cardinality. If set to a value
greater than zero, Redis will stop processing the intersection once the
resulting cardinality reaches this limit.
|
Returns
The cardinality of the intersection or false on failure.
|
#
|