Cluster
class Cluster (View source)
Relay Cluster client.
Constants
OPT_SLAVE_FAILOVER |
Integer representing the failover option. |
FAILOVER_NONE |
Integer representing no failover. Enabled by default. Send commands to master nodes only. |
FAILOVER_ERROR |
Integer representing error failover. Send readonly commands to slave nodes if master is unreachable. |
FAILOVER_DISTRIBUTE |
Integer representing distribute failover. Always distribute readonly commands between master and slaves, at random |
FAILOVER_DISTRIBUTE_SLAVES |
Integer representing distribute slaves failover. Always distribute readonly commands to the slaves, at random |
Methods
Create a cluster object.
Compress data with Relay's currently configured compression algorithm.
Returns the number of milliseoconds since Relay has received a reply from the cluster.
Returns an array of endpoints along with each of their keys cached in runtime memory.
Return a list of master nodes
Returns the serialized and compressed value.
Returns the value with the prefix.
Returns the serialized value.
Uncompress data with Relay's currently configured compression algorithm.
Returns the unserialized and decompressed value.
Returns the unserialized value.
Interact with Redis' ACLs
Adds allow pattern(s). Only matching keys will be cached in memory.
Adds ignore pattern(s). Matching keys will not be cached in memory.
If key already exists and is a string, this command appends the value at the end of the string. If key does not exist it is created and set as an empty string, so APPEND will be similar to SET in this special case.
Asynchronously rewrite the append-only file.
Paus the client until sufficient local and/or remote AOF data has been flushed to disk.
Asynchronously save the dataset to disk.
Count the number of set bits (population counting) in a string.
Perform a bitwise operation on one or more keys, storing the result in a new key.
Return the position of the first bit set to 1 or 0 in a string.
BLMOVE is the blocking variant of LMOVE. When source contains elements, this command behaves exactly like LMOVE. When used inside a MULTI/EXEC block, this command behaves exactly like LMOVE.
Pop elements from a list, or block until one is available
BLPOP is a blocking list pop primitive. It is the blocking version of LPOP because it blocks the connection when there are no elements to pop from any of the given lists.
BRPOP is a blocking list pop primitive. It is the blocking version of RPOP because it blocks the connection when there are no elements to pop from any of the given lists.
Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
Remove and return members with scores in a sorted set or block until one is available
BZPOPMAX is the blocking variant of the sorted set ZPOPMAX primitive.
BZPOPMIN is the blocking variant of the sorted set ZPOPMIN primitive.
Clears the last error that is set, if any.
No description
Executes CLIENT
command operations.
Closes the current connection, if it's persistent.
Executes CLUSTER
command operations.
This is a container command for runtime configuration commands.
Return an array with details about every Redis command.
This command copies the value stored at the source key to the destination key.
Returns the number of keys in the currently-selected database.
Decrements the number stored at key by one.
Decrements the number stored at key by decrement.
Removes the specified keys.
Flushes all previously queued commands in a transaction and restores the connection state to normal.
Dispatches all pending events.
Serialize and return the value stored at key in a Redis-specific format.
Asks Redis to echo back the provided string.
Returns the connection's endpoint identifier.
Evaluate script using the Lua interpreter.
Evaluate script using the Lua interpreter. This is just the "read-only" variant of EVAL meaning it can be run on read-only replicas.
Evaluates a script cached on the server-side by its SHA1 digest.
Evaluates a script cached on the server-side by its SHA1 digest. This is just the "read-only" variant
of EVALSHA
meaning it can be run on read-only replicas.
Executes all previously queued commands in a transaction and restores the connection state to normal.
Returns if key(s) exists.
Set a timeout on key.
Set a timeout on key using a unix timestamp.
Returns the absolute Unix timestamp in seconds at which the given key will expire.
No description
Deletes all the keys of all the existing databases, not just the currently selected one.
Deletes all the keys of the currently selected database.
Add one or more members to a geospacial sorted set
Get the distance between two members of a geospacially encoded sorted set.
Retrieve one or more GeoHash encoded strings for members of the set.
Return the positions (longitude,latitude) of all the specified members of the geospatial index represented by the sorted set at key.
Retrieve members of a geospacially sorted set that are within a certain radius of a location.
Retrieve members of a geospacially sorted set that are within a certain radius of a location.
Similar to GEORADIUS
except it uses a member as the center of the query.
Similar to GEORADIUS
except it uses a member as the center of the query.
Search a geospacial sorted set for members in various ways.
Search a geospacial sorted set for members within a given area or range, storing the results into a new set.
Get the value of key.
Returns the bit value at offset in the string value stored at key.
Get the value of key and optionally set its expiration.
Returns the last error message, if any.
Get the mode Relay is currently in.
Returns a client option.
No description
Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive).
Atomically sets key to value and returns the old value stored at key.
Removes the specified fields from the hash stored at key.
Returns if field is an existing field in the hash stored at key.
Returns the value associated with field in the hash stored at key.
Returns all fields and values of the hash stored at key.
Increments the number stored at field in the hash stored at key by increment.
Increment the specified field of a hash stored at key, and representing a floating point number, by the specified increment.
Returns all field names in the hash stored at key.
Returns the number of fields contained in the hash stored at $key
.
Returns the values associated with the specified fields in the hash stored at key.
Sets the specified fields to their respective values in the hash stored at key.
When called with just the key argument, return a random field from the hash value stored at key.
Iterates fields of Hash types and their associated values.
Sets field in the hash stored at key to value.
Sets field in the hash stored at key to value, only if field does not yet exist.
Returns the string length of the value associated with field in the hash stored at key.
Returns all values in the hash stored at key.
Increments the number stored at key by one.
Increments the number stored at key by increment.
Increment the string representing a floating point number stored at key by the specified increment.
The INFO command returns information and statistics about Redis in a format that is simple to parse by computers and easy to read by humans.
Returns all keys matching pattern.
Returns the UNIX time stamp of the last successful save to disk.
Get the longest common subsequence between two string keys.
Returns the element at index index in the list stored at key.
Inserts element in the list stored at key either before or after the reference value pivot.
Registers a new event listener.
Returns the length of the list stored at $key
.
Atomically returns and removes the first/last element of the list stored at source, and pushes the element at the first/last element of the list stored at destination.
Pops one or more elements from the first non-empty list key from the list of provided key names.
Removes and returns the first elements of the list stored at key.
The command returns the index of matching elements inside a Redis list.
Insert all the specified values at the head of the list stored at key.
Inserts specified values at the head of the list stored at key, only if key already exists and holds a list.
Returns the specified elements of the list stored at key.
Removes the first count occurrences of elements equal to element from the list stored at key.
Sets the list element at index to element.
Trim an existing list so that it will contain only the specified range of elements specified.
Returns the number of bytes allocated, or 0
in client-only mode.
Returns the values of all specified keys.
Sets the given keys to their respective values.
Sets the given keys to their respective values.
Marks the start of a transaction block. Subsequent commands will be queued for atomic execution using EXEC.
This is a container command for object introspection commands.
Registers a new flushed
event listener.
Registers a new invalidated
event listener.
Remove the existing timeout on key, turning the key from volatile to persistent.
Set a key's time to live in milliseconds.
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
Semantic the same as EXPIRETIME, but returns the absolute Unix expiration timestamp in milliseconds instead of seconds.
Adds the specified elements to the specified HyperLogLog.
Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
Merge given HyperLogLogs into a single one.
Returns PONG if no argument is provided, otherwise return a copy of the argument as a bulk.
Set key to hold the string value and set key to timeout after a given number of milliseconds.
Subscribes to the given patterns.
Returns the remaining time to live of a key that has a timeout in milliseconds.
Posts a message to the given channel.
A container command for Pub/Sub introspection commands.
Unsubscribes from the given patterns, or from all of them if none is given.
Returns a random key from Redis.
Execute any command against Redis, without applying the prefix, compression and serialization.
Renames key.
Renames key if the new key does not yet exist.
Create a key associated with a value that is obtained by deserializing the provided serialized value.
Returns the role of the instance in the context of replication.
Removes and returns the last elements of the list stored at key.
Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
Insert all the specified values at the tail of the list stored at key.
Inserts specified values at the tail of the list stored at key, only if key already exists and holds a list.
Add the specified members to the set stored at $key
.
Synchronously save the dataset to disk.
Scan the keyspace for matching keys.
Returns the set cardinality (number of elements) of the set stored at $key
.
Execute a script management command.
Returns the members of the set resulting from the difference between the first set and all the successive sets.
This command is equal to SDIFF, but instead of returning the resulting set, it is stored in destination.
Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type.
Sets a client option.
Sets or clears the bit at offset in the string value stored at key.
Set key to hold the string value and set key to timeout after a given number of seconds.
Set key to hold string value if key does not exist. In that case, it is equal to SET.
Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.
Returns the members of the set resulting from the intersection of all the given sets.
Intersect multiple sets and return the cardinality of the result.
This command is equal to SINTER, but instead of returning the resulting set, it is stored in destination.
Returns if $member
is a member of the set stored at $key
.
Interact with the Redis slowlog.
Returns all the members of the set value stored at $key
.
Returns whether each member is a member of the set stored at $key
.
Move member from the set at source to the set at destination.
Sort the elements in a list, set or sorted set.
Sort the elements in a list, set or sorted set. Read-only variant of SORT.
Removes and returns one or more random members from the set value store at $key
.
Returns one or multiple random members from a set.
Remove the specified members from the set stored at $key
.
Iterates elements of Sets types.
Subscribes to the specified shard channels.
Returns statistics about Relay.
Returns the length of the string value stored at $key
.
Subscribes to the specified channels.
Returns the members of the set resulting from the union of all the given sets.
This command is equal to SUNION, but instead of returning the resulting set, it is stored in destination.
Unsubscribes from the given shard channels, or from all of them if none is given.
Returns the current time from Redis.
Alters the last access time of a key(s).
Returns the remaining time to live of a key that has a timeout in seconds.
Returns the type of a given key.
Removes the specified keys without blocking Redis.
Unsubscribes from the given channels, or from all of them if none is given.
Flushes all the previously watched keys for a transaction.
Marks the given keys to be watched for conditional execution of a transaction.
Acknowledge one or more IDs as having been processed by the consumer group.
Append a message to a stream.
Automatically take ownership of stream message(s) by metrics
Claim ownership of stream message(s).
Remove one or more specific IDs from a stream.
Perform utility operations having to do with consumer groups
Retrieve information about a stream key.
Get the length of a stream.
Query pending entries in a stream.
Lists elements in a stream.
Read messages from a stream.
Read messages from a stream using a consumer group.
Get a range of entries from a STREAM ke in reverse chronological order.
Truncate a STREAM key in various ways.
Adds all the specified members with the specified scores to the sorted set stored at key.
Returns the sorted set cardinality (number of elements) of the sorted set stored at key.
Returns the number of elements in the sorted set at key with a score between min and max.
This command is similar to ZDIFFSTORE, but instead of storing the resulting sorted set, it is returned to the client.
Computes the difference between the first and all successive input sorted sets and stores the result in destination.
Increments the score of member in the sorted set stored at key by increment.
This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the client.
Intersect multiple sorted sets and return the cardinality of the result.
Computes the intersection of numkeys sorted sets given by the specified keys, and stores the result in destination.
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at key with a value between min and max.
Pops one or more elements, that are member-score pairs, from the first non-empty sorted set in the provided list of key names.
Returns the scores associated with the specified members in the sorted set stored at key.
Removes and returns up to count members with the highest scores in the sorted set stored at key.
Removes and returns up to count members with the lowest scores in the sorted set stored at key.
When called with just the key argument, return a random element from the sorted set value stored at key.
Returns the specified range of elements in the sorted set stored at key.
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.
Returns all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max).
Returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min).
Returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0.
Removes the specified members from the sorted set stored at key.
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.
Removes all elements in the sorted set stored at key with rank between start and stop. Both start and stop are 0 -based indexes with 0 being the element with the lowest score.
Removes all elements in the sorted set stored at key with a score between min and max (inclusive).
Returns the specified range of elements in the sorted set stored at key.
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between max and min.
Returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min).
Returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.
Iterates elements of Sorted Set types and their associated scores.
Returns the score of member in the sorted set at key.
This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the client.
Computes the union of numkeys sorted sets given by the specified keys, and stores the result in destination.
Details
__construct(string|null $name, array|null $seeds = null, int|float $connect_timeout = 0, int|float $command_timeout = 0, bool $persistent = false, mixed $auth = null, array|null $context = null)
Create a cluster object.
string
_compress(string $value)
Compress data with Relay's currently configured compression algorithm.
int
idleTime()
Returns the number of milliseoconds since Relay has received a reply from the cluster.
array|false
_getKeys()
internal | Temporary debug helper. Do not use. |
Returns an array of endpoints along with each of their keys cached in runtime memory.
array
_masters()
Return a list of master nodes
string
_pack(mixed $value)
Returns the serialized and compressed value.
string
_prefix(mixed $value)
Returns the value with the prefix.
string
_serialize(mixed $value)
Returns the serialized value.
string
_uncompress(string $value)
Uncompress data with Relay's currently configured compression algorithm.
mixed
_unpack(string $value)
Returns the unserialized and decompressed value.
mixed
_unserialize(string $value)
Returns the unserialized value.
mixed
acl(array|string $key_or_address, string $operation, string ...$args)
Interact with Redis' ACLs
int
addAllowPatterns(string ...$pattern)
Adds allow pattern(s). Only matching keys will be cached in memory.
int
addIgnorePatterns(string ...$pattern)
Adds ignore pattern(s). Matching keys will not be cached in memory.
Cluster|int|false
append(mixed $key, mixed $value)
If key already exists and is a string, this command appends the value at the end of the string. If key does not exist it is created and set as an empty string, so APPEND will be similar to SET in this special case.
Cluster|bool
bgrewriteaof(array|string $key_or_address)
Asynchronously rewrite the append-only file.
Relay|array|false
waitaof(array|string $key_or_address, int $numlocal, int $numremote, int $timeout)
Paus the client until sufficient local and/or remote AOF data has been flushed to disk.
Cluster|bool
bgsave(array|string $key_or_address, bool $schedule = false)
Asynchronously save the dataset to disk.
Cluster|int|false
bitcount(mixed $key, int $start = 0, int $end = -1, bool $by_bit = false)
Count the number of set bits (population counting) in a string.
Cluster|int|false
bitop(string $operation, string $dstkey, string $srckey, string ...$other_keys)
Perform a bitwise operation on one or more keys, storing the result in a new key.
Cluster|int|false
bitpos(mixed $key, int $bit, int $start = null, int $end = null, bool $by_bit = false)
Return the position of the first bit set to 1 or 0 in a string.
Cluster|string|null|false
blmove(mixed $srckey, mixed $dstkey, string $srcpos, string $dstpos, float $timeout)
BLMOVE is the blocking variant of LMOVE. When source contains elements, this command behaves exactly like LMOVE. When used inside a MULTI/EXEC block, this command behaves exactly like LMOVE.
mixed
blmpop(float $timeout, array $keys, string $from, int $count = 1)
Pop elements from a list, or block until one is available
Cluster|array|null|false
blpop(string|array $key, string|float $timeout_or_key, mixed ...$extra_args)
BLPOP is a blocking list pop primitive. It is the blocking version of LPOP because it blocks the connection when there are no elements to pop from any of the given lists.
Cluster|array|null|false
brpop(string|array $key, string|float $timeout_or_key, mixed ...$extra_args)
BRPOP is a blocking list pop primitive. It is the blocking version of RPOP because it blocks the connection when there are no elements to pop from any of the given lists.
mixed
brpoplpush(mixed $srckey, mixed $dstkey, float $timeout)
Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
This command will block for an element up to the provided timeout.
Cluster|array|null|false
bzmpop(float $timeout, array $keys, string $from, int $count = 1)
Remove and return members with scores in a sorted set or block until one is available
Cluster|array|null|false
bzpopmax(string|array $key, string|float $timeout_or_key, mixed ...$extra_args)
BZPOPMAX is the blocking variant of the sorted set ZPOPMAX primitive.
Cluster|array|null|false
bzpopmin(string|array $key, string|float $timeout_or_key, mixed ...$extra_args)
BZPOPMIN is the blocking variant of the sorted set ZPOPMIN primitive.
bool
clearLastError()
Clears the last error that is set, if any.
bool
clearTransferredBytes()
No description
mixed
client(array|string $key_or_address, string $operation, mixed ...$args)
Executes CLIENT
command operations.
bool
close()
Closes the current connection, if it's persistent.
mixed
cluster(array|string $key_or_address, string $operation, mixed ...$args)
Executes CLUSTER
command operations.
mixed
config(array|string $key_or_address, string $operation, mixed ...$args)
This is a container command for runtime configuration commands.
Cluster|array|int|false
command(mixed ...$args)
Return an array with details about every Redis command.
Cluster|bool
copy(mixed $srckey, mixed $dstkey, array|null $options = null)
This command copies the value stored at the source key to the destination key.
Cluster|int|false
dbsize(array|string $key_or_address)
Returns the number of keys in the currently-selected database.
Cluster|int|false
decr(mixed $key, int $by = 1)
Decrements the number stored at key by one.
Cluster|int|false
decrby(mixed $key, int $value)
Decrements the number stored at key by decrement.
Cluster|int|bool
del(mixed ...$keys)
Removes the specified keys.
bool
discard()
Flushes all previously queued commands in a transaction and restores the connection state to normal.
If WATCH was used, DISCARD unwatches all keys watched by the connection.
int|false
dispatchEvents()
Dispatches all pending events.
Cluster|string|false
dump(mixed $key)
Serialize and return the value stored at key in a Redis-specific format.
Cluster|string|false
echo(array|string $key_or_address, string $message)
Asks Redis to echo back the provided string.
array|false
endpointId()
Returns the connection's endpoint identifier.
mixed
eval(mixed $script, array $args = [], int $num_keys = 0)
Evaluate script using the Lua interpreter.
mixed
eval_ro(mixed $script, array $args = [], int $num_keys = 0)
Evaluate script using the Lua interpreter. This is just the "read-only" variant of EVAL meaning it can be run on read-only replicas.
mixed
evalsha(string $sha, array $args = [], int $num_keys = 0)
Evaluates a script cached on the server-side by its SHA1 digest.
mixed
evalsha_ro(string $sha, array $args = [], int $num_keys = 0)
Evaluates a script cached on the server-side by its SHA1 digest. This is just the "read-only" variant
of EVALSHA
meaning it can be run on read-only replicas.
array|false
exec()
Executes all previously queued commands in a transaction and restores the connection state to normal.
Cluster|int|bool
exists(mixed ...$keys)
Returns if key(s) exists.
Cluster|bool
expire(mixed $key, int $seconds, string|null $mode = null)
Set a timeout on key.
Cluster|bool
expireat(mixed $key, int $timestamp)
Set a timeout on key using a unix timestamp.
Cluster|int|false
expiretime(mixed $key)
Returns the absolute Unix timestamp in seconds at which the given key will expire.
If the key exists but doesn't have a TTL this function return -1. If the key does not exist -2.
static bool
flushMemory(string|null $endpointId = null, int $db = null)
No description
Cluster|bool
flushall(array|string $key_or_address, bool|null $sync = null)
Deletes all the keys of all the existing databases, not just the currently selected one.
Cluster|bool
flushdb(array|string $key_or_address, bool|null $sync = null)
Deletes all the keys of the currently selected database.
Cluster|int|false
geoadd(mixed $key, float $lng, float $lat, string $member, mixed ...$other_triples_and_options)
Add one or more members to a geospacial sorted set
Cluster|float|false
geodist(mixed $key, string $src, string $dst, string|null $unit = null)
Get the distance between two members of a geospacially encoded sorted set.
Cluster|array|false
geohash(mixed $key, string $member, string ...$other_members)
Retrieve one or more GeoHash encoded strings for members of the set.
Cluster|array|false
geopos(mixed $key, mixed ...$members)
Return the positions (longitude,latitude) of all the specified members of the geospatial index represented by the sorted set at key.
mixed
georadius(mixed $key, float $lng, float $lat, float $radius, string $unit, array $options = [])
Retrieve members of a geospacially sorted set that are within a certain radius of a location.
mixed
georadius_ro(mixed $key, float $lng, float $lat, float $radius, string $unit, array $options = [])
Retrieve members of a geospacially sorted set that are within a certain radius of a location.
mixed
georadiusbymember(mixed $key, string $member, float $radius, string $unit, array $options = [])
Similar to GEORADIUS
except it uses a member as the center of the query.
mixed
georadiusbymember_ro(mixed $key, string $member, float $radius, string $unit, array $options = [])
Similar to GEORADIUS
except it uses a member as the center of the query.
Cluster|array
geosearch(mixed $key, array|string $position, array|int|float $shape, string $unit, array $options = [])
Search a geospacial sorted set for members in various ways.
Cluster|int|false
geosearchstore(mixed $dstkey, mixed $srckey, array|string $position, array|int|float $shape, string $unit, array $options = [])
Search a geospacial sorted set for members within a given area or range, storing the results into a new set.
mixed
get(mixed $key)
Get the value of key.
Cluster|int|false
getbit(mixed $key, int $pos)
Returns the bit value at offset in the string value stored at key.
mixed
getex(mixed $key, array|null $options = null)
Get the value of key and optionally set its expiration.
GETEX is similar to GET, but is a write command with additional options.
string|null
getLastError()
Returns the last error message, if any.
int
getMode(bool $masked = false)
Get the mode Relay is currently in.
Relay::ATOMIC
or Relay::MULTI
.
mixed
getOption(int $option)
Returns a client option.
array|false
getTransferredBytes()
No description
Cluster|string|false
getrange(mixed $key, int $start, int $end)
Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive).
mixed
getset(mixed $key, mixed $value)
Atomically sets key to value and returns the old value stored at key.
Cluster|int|false
hdel(mixed $key, mixed $member, mixed ...$members)
Removes the specified fields from the hash stored at key.
Cluster|bool
hexists(mixed $key, mixed $member)
Returns if field is an existing field in the hash stored at key.
mixed
hget(mixed $key, mixed $member)
Returns the value associated with field in the hash stored at key.
Cluster|array|false
hgetall(mixed $key)
Returns all fields and values of the hash stored at key.
Cluster|int|false
hincrby(mixed $key, mixed $member, int $value)
Increments the number stored at field in the hash stored at key by increment.
Cluster|float|bool
hincrbyfloat(mixed $key, mixed $member, float $value)
Increment the specified field of a hash stored at key, and representing a floating point number, by the specified increment.
Cluster|array|false
hkeys(mixed $key)
Returns all field names in the hash stored at key.
Cluster|int|false
hlen(mixed $key)
Returns the number of fields contained in the hash stored at $key
.
Cluster|array|false
hmget(mixed $key, array $members)
Returns the values associated with the specified fields in the hash stored at key.
Cluster|bool
hmset(mixed $key, array $members)
Sets the specified fields to their respective values in the hash stored at key.
Cluster|array|string|false
hrandfield(mixed $key, array|null $options = null)
When called with just the key argument, return a random field from the hash value stored at key.
array|false
hscan(mixed $key, mixed $iterator, mixed $match = null, int $count = 0)
Iterates fields of Hash types and their associated values.
Cluster|int|false
hset(mixed $key, mixed $member, mixed $value, mixed ...$kvals)
Sets field in the hash stored at key to value.
Cluster|bool
hsetnx(mixed $key, mixed $member, mixed $value)
Sets field in the hash stored at key to value, only if field does not yet exist.
Cluster|int|false
hstrlen(mixed $key, mixed $member)
Returns the string length of the value associated with field in the hash stored at key.
Cluster|array|false
hvals(mixed $key)
Returns all values in the hash stored at key.
Cluster|int|false
incr(mixed $key, int $by = 1)
Increments the number stored at key by one.
Cluster|int|false
incrby(mixed $key, int $value)
Increments the number stored at key by increment.
Cluster|float|false
incrbyfloat(mixed $key, float $value)
Increment the string representing a floating point number stored at key by the specified increment.
Cluster|array|false
info(array|string $key_or_address, string ...$sections)
The INFO command returns information and statistics about Redis in a format that is simple to parse by computers and easy to read by humans.
Cluster|array|false
keys(mixed $pattern)
Returns all keys matching pattern.
Cluster|int|false
lastsave(array|string $key_or_address)
Returns the UNIX time stamp of the last successful save to disk.
mixed
lcs(mixed $key1, mixed $key2, array|null $options = null)
Get the longest common subsequence between two string keys.
mixed
lindex(mixed $key, int $index)
Returns the element at index index in the list stored at key.
Cluster|int|false
linsert(mixed $key, string $op, mixed $pivot, mixed $element)
Inserts element in the list stored at key either before or after the reference value pivot.
bool
listen(callable|null $callback)
Registers a new event listener.
Cluster|int|false
llen(mixed $key)
Returns the length of the list stored at $key
.
Cluster|string|null|false
lmove(mixed $srckey, mixed $dstkey, string $srcpos, string $dstpos)
Atomically returns and removes the first/last element of the list stored at source, and pushes the element at the first/last element of the list stored at destination.
mixed
lmpop(array $keys, string $from, int $count = 1)
Pops one or more elements from the first non-empty list key from the list of provided key names.
mixed
lpop(mixed $key, int $count = 1)
Removes and returns the first elements of the list stored at key.
mixed
lpos(mixed $key, mixed $value, array|null $options = null)
The command returns the index of matching elements inside a Redis list.
Cluster|int|false
lpush(mixed $key, mixed $member, mixed ...$members)
Insert all the specified values at the head of the list stored at key.
Cluster|int|false
lpushx(mixed $key, mixed $member, mixed ...$members)
Inserts specified values at the head of the list stored at key, only if key already exists and holds a list.
Cluster|array|false
lrange(mixed $key, int $start, int $stop)
Returns the specified elements of the list stored at key.
Cluster|int|false
lrem(mixed $key, mixed $member, int $count = 0)
Removes the first count occurrences of elements equal to element from the list stored at key.
Cluster|bool
lset(mixed $key, int $index, mixed $member)
Sets the list element at index to element.
Cluster|bool
ltrim(mixed $key, int $start, int $end)
Trim an existing list so that it will contain only the specified range of elements specified.
static int
maxMemory()
Returns the number of bytes allocated, or 0
in client-only mode.
Cluster|array|false
mget(array $keys)
Returns the values of all specified keys.
Cluster|array|bool
mset(array $kvals)
Sets the given keys to their respective values.
MSET replaces existing values with new values, just as regular SET.
Cluster|array|bool
msetnx(array $kvals)
Sets the given keys to their respective values.
MSETNX will not perform any operation at all even if just a single key already exists.
Cluster|bool
multi(int $mode = Relay::MULTI)
Marks the start of a transaction block. Subsequent commands will be queued for atomic execution using EXEC.
Accepts only Relay::MULTI
mode.
mixed
object(string $op, mixed $key)
This is a container command for object introspection commands.
bool
onFlushed(callable|null $callback)
Registers a new flushed
event listener.
bool
onInvalidated(callable|null $callback, string|null $pattern = null)
Registers a new invalidated
event listener.
Cluster|bool
persist(mixed $key)
Remove the existing timeout on key, turning the key from volatile to persistent.
Cluster|bool
pexpire(mixed $key, int $milliseconds)
Set a key's time to live in milliseconds.
Cluster|bool
pexpireat(mixed $key, int $timestamp_ms)
Set the expiration for a key as a UNIX timestamp specified in milliseconds.
Cluster|int|false
pexpiretime(mixed $key)
Semantic the same as EXPIRETIME, but returns the absolute Unix expiration timestamp in milliseconds instead of seconds.
Cluster|int|false
pfadd(mixed $key, array $elements)
Adds the specified elements to the specified HyperLogLog.
Cluster|int|false
pfcount(mixed $key)
Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
Cluster|bool
pfmerge(string $dstkey, array $srckeys)
Merge given HyperLogLogs into a single one.
Cluster|bool|string
ping(array|string $key_or_address, string|null $message = null)
Returns PONG if no argument is provided, otherwise return a copy of the argument as a bulk.
Cluster|bool
psetex(mixed $key, int $milliseconds, mixed $value)
Set key to hold the string value and set key to timeout after a given number of milliseconds.
bool
psubscribe(array $patterns, callable $callback)
Subscribes to the given patterns.
Cluster|int|false
pttl(mixed $key)
Returns the remaining time to live of a key that has a timeout in milliseconds.
Cluster|int|false
publish(string $channel, string $message)
Posts a message to the given channel.
mixed
pubsub(array|string $key_or_address, string $operation, mixed ...$args)
A container command for Pub/Sub introspection commands.
bool
punsubscribe(array $patterns = [])
Unsubscribes from the given patterns, or from all of them if none is given.
Cluster|bool|string
randomkey(array|string $key_or_address)
Returns a random key from Redis.
mixed
rawCommand(array|string $key_or_address, string $cmd, mixed ...$args)
Execute any command against Redis, without applying the prefix, compression and serialization.
Cluster|bool
rename(mixed $key, mixed $newkey)
Renames key.
Cluster|bool
renamenx(mixed $key, mixed $newkey)
Renames key if the new key does not yet exist.
Cluster|bool
restore(mixed $key, int $ttl, string $value, array|null $options = null)
Create a key associated with a value that is obtained by deserializing the provided serialized value.
Cluster|array|false
role(array|string $key_or_address)
Returns the role of the instance in the context of replication.
mixed
rpop(mixed $key, int $count = 1)
Removes and returns the last elements of the list stored at key.
mixed
rpoplpush(mixed $srckey, mixed $dstkey)
Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
Cluster|int|false
rpush(mixed $key, mixed $member, mixed ...$members)
Insert all the specified values at the tail of the list stored at key.
Cluster|int|false
rpushx(mixed $key, mixed $member, mixed ...$members)
Inserts specified values at the tail of the list stored at key, only if key already exists and holds a list.
Cluster|int|false
sadd(mixed $key, mixed $member, mixed ...$members)
Add the specified members to the set stored at $key
.
Cluster|bool
save(array|string $key_or_address)
Synchronously save the dataset to disk.
array|false
scan(mixed $iterator, array|string $key_or_address, mixed $match = null, int $count = 0, string|null $type = null)
Scan the keyspace for matching keys.
Cluster|int|false
scard(mixed $key)
Returns the set cardinality (number of elements) of the set stored at $key
.
mixed
script(array|string $key_or_address, string $operation, string ...$args)
Execute a script management command.
Cluster|array|false
sdiff(mixed $key, mixed ...$other_keys)
Returns the members of the set resulting from the difference between the first set and all the successive sets.
Cluster|int|false
sdiffstore(mixed $key, mixed ...$other_keys)
This command is equal to SDIFF, but instead of returning the resulting set, it is stored in destination.
If destination already exists, it is overwritten.
Cluster|string|bool
set(mixed $key, mixed $value, mixed $options = null)
Set key to hold the string value. If key already holds a value, it is overwritten, regardless of its type.
bool
setOption(int $option, mixed $value)
Sets a client option.
Relay specific options:
OPT_ALLOW_PATTERNS
OPT_IGNORE_PATTERNS
OPT_THROW_ON_ERROR
OPT_CLIENT_INVALIDATIONS
OPT_PHPREDIS_COMPATIBILITY
Supported PhpRedis options:
OPT_PREFIX
OPT_READ_TIMEOUT
OPT_COMPRESSION
OPT_COMPRESSION_LEVEL
OPT_MAX_RETRIES
OPT_BACKOFF_ALGORITHM
OPT_BACKOFF_BASE
OPT_BACKOFF_CAP
OPT_SCAN
OPT_REPLY_LITERAL
OPT_NULL_MULTIBULK_AS_NULL
OPT_SLAVE_FAILOVER
Cluster|int|false
setbit(mixed $key, int $pos, int $value)
Sets or clears the bit at offset in the string value stored at key.
Cluster|bool
setex(mixed $key, int $seconds, mixed $value)
Set key to hold the string value and set key to timeout after a given number of seconds.
Cluster|bool
setnx(mixed $key, mixed $value)
Set key to hold string value if key does not exist. In that case, it is equal to SET.
When key already holds a value, no operation is performed. SETNX is short for "SET if Not eXists".
Cluster|int|false
setrange(mixed $key, int $start, mixed $value)
Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.
Cluster|array|false
sinter(mixed $key, mixed ...$other_keys)
Returns the members of the set resulting from the intersection of all the given sets.
Cluster|int|false
sintercard(array $keys, int $limit = -1)
Intersect multiple sets and return the cardinality of the result.
Cluster|int|false
sinterstore(mixed $key, mixed ...$other_keys)
This command is equal to SINTER, but instead of returning the resulting set, it is stored in destination.
If destination already exists, it is overwritten.
Cluster|bool
sismember(mixed $key, mixed $member)
Returns if $member
is a member of the set stored at $key
.
Cluster|array|int|bool
slowlog(array|string $key_or_address, string $operation, mixed ...$args)
Interact with the Redis slowlog.
Cluster|array|false
smembers(mixed $key)
Returns all the members of the set value stored at $key
.
Cluster|array|false
smismember(mixed $key, mixed ...$members)
Returns whether each member is a member of the set stored at $key
.
Cluster|bool
smove(mixed $srckey, mixed $dstkey, mixed $member)
Move member from the set at source to the set at destination.
Cluster|array|int|false
sort(mixed $key, array $options = [])
Sort the elements in a list, set or sorted set.
Cluster|array|int|false
sort_ro(mixed $key, array $options = [])
Sort the elements in a list, set or sorted set. Read-only variant of SORT.
mixed
spop(mixed $key, int $count = 1)
Removes and returns one or more random members from the set value store at $key
.
mixed
srandmember(mixed $key, int $count = 1)
Returns one or multiple random members from a set.
Cluster|int|false
srem(mixed $key, mixed $member, mixed ...$members)
Remove the specified members from the set stored at $key
.
array|false
sscan(mixed $key, mixed $iterator, mixed $match = null, int $count = 0)
Iterates elements of Sets types.
bool
ssubscribe(array $channels, callable $callback)
Subscribes to the specified shard channels.
static array
stats()
Returns statistics about Relay.
Cluster|int|false
strlen(mixed $key)
Returns the length of the string value stored at $key
.
bool
subscribe(array $channels, callable $callback)
Subscribes to the specified channels.
Cluster|array|false
sunion(mixed $key, mixed ...$other_keys)
Returns the members of the set resulting from the union of all the given sets.
Cluster|int|false
sunionstore(mixed $key, mixed ...$other_keys)
This command is equal to SUNION, but instead of returning the resulting set, it is stored in destination.
If destination already exists, it is overwritten.
bool
sunsubscribe(array $channels = [])
Unsubscribes from the given shard channels, or from all of them if none is given.
Cluster|array|false
time(array|string $key_or_address)
Returns the current time from Redis.
Cluster|int|false
touch(array|string $key_or_array, mixed ...$more_keys)
Alters the last access time of a key(s).
Cluster|int|false
ttl(mixed $key)
Returns the remaining time to live of a key that has a timeout in seconds.
Cluster|int|string|bool
type(mixed $key)
Returns the type of a given key.
In PhpRedis compatibility mode this will return an integer
(one of the REDIS_
Cluster|int|false
unlink(mixed ...$keys)
Removes the specified keys without blocking Redis.
bool
unsubscribe(array $channels = [])
Unsubscribes from the given channels, or from all of them if none is given.
Cluster|bool
unwatch()
Flushes all the previously watched keys for a transaction.
If you call EXEC or DISCARD, there's no need to manually call UNWATCH.
Cluster|bool
watch(mixed $key, mixed ...$other_keys)
Marks the given keys to be watched for conditional execution of a transaction.
Cluster|int|false
xack(mixed $key, string $group, array $ids)
Acknowledge one or more IDs as having been processed by the consumer group.
Cluster|string|false
xadd(mixed $key, string $id, array $values, int $maxlen = 0, bool $approx = false, bool $nomkstream = false)
Append a message to a stream.
Cluster|bool|array
xautoclaim(mixed $key, string $group, string $consumer, int $min_idle, string $start, int $count = -1, bool $justid = false)
Automatically take ownership of stream message(s) by metrics
Cluster|array|bool
xclaim(mixed $key, string $group, string $consumer, int $min_idle, array $ids, array $options)
Claim ownership of stream message(s).
Cluster|int|false
xdel(mixed $key, array $ids)
Remove one or more specific IDs from a stream.
mixed
xgroup(string $operation, mixed $key = null, string $group = null, string $id_or_consumer = null, bool $mkstream = false, int $entries_read = -2)
Perform utility operations having to do with consumer groups
mixed
xinfo(string $operation, string|null $arg1 = null, string|null $arg2 = null, int $count = -1)
Retrieve information about a stream key.
Cluster|int|false
xlen(mixed $key)
Get the length of a stream.
Cluster|array|false
xpending(mixed $key, string $group, string|null $start = null, string|null $end = null, int $count = -1, string|null $consumer = null, int $idle = 0)
Query pending entries in a stream.
Cluster|array|false
xrange(mixed $key, string $start, string $end, int $count = -1)
Lists elements in a stream.
Cluster|array|bool|null
xread(array $streams, int $count = -1, int $block = -1)
Read messages from a stream.
Cluster|array|bool|null
xreadgroup(mixed $key, string $consumer, array $streams, int $count = 1, int $block = 1)
Read messages from a stream using a consumer group.
Cluster|array|bool
xrevrange(mixed $key, string $end, string $start, int $count = -1)
Get a range of entries from a STREAM ke in reverse chronological order.
Cluster|int|false
xtrim(mixed $key, string $threshold, bool $approx = false, bool $minid = false, int $limit = -1)
Truncate a STREAM key in various ways.
mixed
zadd(mixed $key, mixed ...$args)
Adds all the specified members with the specified scores to the sorted set stored at key.
Cluster|int|false
zcard(mixed $key)
Returns the sorted set cardinality (number of elements) of the sorted set stored at key.
Cluster|int|false
zcount(mixed $key, mixed $min, mixed $max)
Returns the number of elements in the sorted set at key with a score between min and max.
Cluster|array|false
zdiff(array $keys, array|null $options = null)
This command is similar to ZDIFFSTORE, but instead of storing the resulting sorted set, it is returned to the client.
Cluster|int|false
zdiffstore(mixed $dstkey, array $keys)
Computes the difference between the first and all successive input sorted sets and stores the result in destination.
Cluster|float|false
zincrby(mixed $key, float $score, mixed $member)
Increments the score of member in the sorted set stored at key by increment.
Cluster|array|false
zinter(array $keys, array|null $weights = null, mixed $options = null)
This command is similar to ZINTERSTORE, but instead of storing the resulting sorted set, it is returned to the client.
Cluster|int|false
zintercard(array $keys, int $limit = -1)
Intersect multiple sorted sets and return the cardinality of the result.
Cluster|int|false
zinterstore(mixed $dstkey, array $keys, array|null $weights = null, mixed $options = null)
Computes the intersection of numkeys sorted sets given by the specified keys, and stores the result in destination.
Cluster|int|false
zlexcount(mixed $key, mixed $min, mixed $max)
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at key with a value between min and max.
Cluster|array|null|false
zmpop(array $keys, string $from, int $count = 1)
Pops one or more elements, that are member-score pairs, from the first non-empty sorted set in the provided list of key names.
Cluster|array|false
zmscore(mixed $key, mixed ...$members)
Returns the scores associated with the specified members in the sorted set stored at key.
Cluster|array|false
zpopmax(mixed $key, int $count = 1)
Removes and returns up to count members with the highest scores in the sorted set stored at key.
Cluster|array|false
zpopmin(mixed $key, int $count = 1)
Removes and returns up to count members with the lowest scores in the sorted set stored at key.
mixed
zrandmember(mixed $key, array|null $options = null)
When called with just the key argument, return a random element from the sorted set value stored at key.
If the provided count argument is positive, return an array of distinct elements.
Cluster|array|false
zrange(mixed $key, string $start, string $end, mixed $options = null)
Returns the specified range of elements in the sorted set stored at key.
Cluster|array|false
zrangebylex(mixed $key, mixed $min, mixed $max, int $offset = -1, int $count = -1)
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between min and max.
Cluster|array|false
zrangebyscore(mixed $key, mixed $start, mixed $end, mixed $options = null)
Returns all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max).
Cluster|int|false
zrangestore(mixed $dstkey, mixed $srckey, mixed $start, mixed $end, mixed $options = null)
Returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min).
Cluster|array|int|false
zrank(mixed $key, mixed $rank, bool $withscore = false)
Returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0.
Cluster|int|false
zrem(mixed $key, mixed ...$args)
Removes the specified members from the sorted set stored at key.
Non existing members are ignored.
Cluster|int|false
zremrangebylex(mixed $key, mixed $min, mixed $max)
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command removes all elements in the sorted set stored at key between the lexicographical range specified by min and max.
Cluster|int|false
zremrangebyrank(mixed $key, int $start, int $end)
Removes all elements in the sorted set stored at key with rank between start and stop. Both start and stop are 0 -based indexes with 0 being the element with the lowest score.
Cluster|int|false
zremrangebyscore(mixed $key, mixed $min, mixed $max)
Removes all elements in the sorted set stored at key with a score between min and max (inclusive).
Cluster|array|false
zrevrange(mixed $key, int $start, int $end, mixed $options = null)
Returns the specified range of elements in the sorted set stored at key.
Cluster|array|false
zrevrangebylex(mixed $key, mixed $max, mixed $min, int $offset = -1, int $count = -1)
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns all the elements in the sorted set at key with a value between max and min.
Cluster|array|false
zrevrangebyscore(mixed $key, mixed $start, mixed $end, mixed $options = null)
Returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min).
Cluster|array|int|false
zrevrank(mixed $key, mixed $rank, bool $withscore = false)
Returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.
array|false
zscan(mixed $key, mixed $iterator, mixed $match = null, int $count = 0)
Iterates elements of Sorted Set types and their associated scores.
Cluster|float|false
zscore(mixed $key, mixed $member)
Returns the score of member in the sorted set at key.
Cluster|array|false
zunion(array $keys, array|null $weights = null, mixed $options = null)
This command is similar to ZUNIONSTORE, but instead of storing the resulting sorted set, it is returned to the client.
Cluster|int|false
zunionstore(mixed $dstkey, array $keys, array|null $weights = null, mixed $options = null)
Computes the union of numkeys sorted sets given by the specified keys, and stores the result in destination.