Connection
extends Component
in package
The redis connection class is used to establish a connection to a [redis](https://redis.io/) server.
By default it assumes there is a redis server running on localhost at port 6379 and uses the database number 0.
It is possible to connect to a redis server using [[hostname]] and [[port]] or using a [[unixSocket]].
It also supports the AUTH command of redis. When the server needs authentication, you can set the [[password]] property to authenticate with the server after connect.
The execution of redis commands is possible with via [[executeCommand()]].
Tags
Table of Contents
Constants
- EVENT_AFTER_OPEN = 'afterOpen'
Properties
- $behaviors : array<string|int, Behavior>
- $connectionString : string
- $connectionTimeout : float
- $contextOptions : array<string|int, mixed>
- $database : int
- $dataTimeout : float
- $driverName : string
- $hostname : string
- $isActive : bool
- $luaScriptBuilder : LuaScriptBuilder
- $password : string
- $port : int
- $redirectConnectionString : string
- $redisCommands : array<string|int, mixed>
- $retries : int
- $retryInterval : int
- $scheme : string
- $socket : resource|false
- $socketClientFlags : int
- $unixSocket : string
- $username : string|null
- $useSSL : bool
- $_behaviors : array<string|int, Behavior>|null
- $_events : array<string|int, mixed>
- $_eventWildcards : array<string|int, mixed>
- $_pool : array<string|int, mixed>
Methods
- __call() : mixed
- Allows issuing all supported commands via magic methods.
- __clone() : mixed
- This method is called after the object is created by cloning an existing one.
- __construct() : mixed
- Constructor.
- __get() : mixed
- Returns the value of a component property.
- __isset() : bool
- Checks if a property is set, i.e. defined and not null.
- __set() : mixed
- Sets the value of a component property.
- __sleep() : array<string|int, mixed>
- Closes the connection when this component is being serialized.
- __unset() : mixed
- Sets a component property to be null.
- append() : mixed
- attachBehavior() : Behavior
- Attaches a behavior to this component.
- attachBehaviors() : mixed
- Attaches a list of behaviors to the component.
- auth() : mixed
- behaviors() : array<string|int, mixed>
- Returns a list of behaviors that this component should behave as.
- bgrewriteaof() : mixed
- bgsave() : mixed
- bitcount() : mixed
- bitfield() : mixed
- bitop() : mixed
- bitpos() : mixed
- blpop() : mixed
- brpop() : mixed
- brpoplpush() : mixed
- canGetProperty() : bool
- Returns a value indicating whether a property can be read.
- canSetProperty() : bool
- Returns a value indicating whether a property can be set.
- className() : string
- Returns the fully qualified name of this class.
- clientGetname() : mixed
- clientKill() : mixed
- clientList() : mixed
- clientPause() : mixed
- clientReply() : mixed
- clientSetname() : mixed
- close() : mixed
- Closes the currently active DB connection.
- clusterAddslots() : mixed
- clusterCountkeysinslot() : mixed
- clusterDelslots() : mixed
- clusterFailover() : mixed
- clusterForget() : mixed
- clusterGetkeysinslot() : mixed
- clusterInfo() : mixed
- clusterKeyslot() : mixed
- clusterMeet() : mixed
- clusterNodes() : mixed
- clusterReplicate() : mixed
- clusterReset() : mixed
- clusterSaveconfig() : mixed
- clusterSetslot() : mixed
- clusterSlaves() : mixed
- clusterSlots() : mixed
- command() : mixed
- commandCount() : mixed
- commandGetkeys() : mixed
- commandInfo() : mixed
- configGet() : mixed
- configResetstat() : mixed
- configRewrite() : mixed
- configSet() : mixed
- dbsize() : mixed
- debugObject() : mixed
- debugSegfault() : mixed
- decr() : mixed
- decrby() : mixed
- del() : mixed
- detachBehavior() : Behavior|null
- Detaches a behavior from the component.
- detachBehaviors() : mixed
- Detaches all behaviors from the component.
- discard() : mixed
- dump() : mixed
- echo() : mixed
- ensureBehaviors() : mixed
- Makes sure that the behaviors declared in [[behaviors()]] are attached to this component.
- eval() : mixed
- evalsha() : mixed
- exec() : mixed
- executeCommand() : array<string|int, mixed>|bool|null|string
- Executes a redis command.
- exists() : mixed
- expire() : mixed
- expireat() : mixed
- flushall() : mixed
- flushdb() : mixed
- geoadd() : mixed
- geodist() : mixed
- geohash() : mixed
- geopos() : mixed
- georadius() : mixed
- georadiusbymember() : mixed
- get() : mixed
- getBehavior() : Behavior|null
- Returns the named behavior object.
- getBehaviors() : array<string|int, Behavior>
- Returns all behaviors attached to this component.
- getbit() : mixed
- getConnectionString() : string
- Return the connection string used to open a socket connection. During a redirect (cluster mode) this will be the target of the redirect.
- getDriverName() : string
- Returns the name of the DB driver for the current [[dsn]].
- getIsActive() : bool
- Returns a value indicating whether the DB connection is established.
- getLuaScriptBuilder() : LuaScriptBuilder
- getrange() : mixed
- getset() : mixed
- getSocket() : resource|false
- Return the connection resource if a connection to the target has been established before, `false` otherwise.
- hasEventHandlers() : bool
- Returns a value indicating whether there is any handler attached to the named event.
- hasMethod() : bool
- Returns a value indicating whether a method is defined.
- hasProperty() : bool
- Returns a value indicating whether a property is defined for this component.
- hdel() : mixed
- hexists() : mixed
- hget() : mixed
- hgetall() : mixed
- hincrby() : mixed
- hincrbyfloat() : mixed
- hkeys() : mixed
- hlen() : mixed
- hmget() : mixed
- hmset() : mixed
- hscan() : mixed
- hset() : mixed
- hsetnx() : mixed
- hstrlen() : mixed
- hvals() : mixed
- incr() : mixed
- incrby() : mixed
- incrbyfloat() : mixed
- info() : mixed
- init() : mixed
- Initializes the object.
- keys() : mixed
- lastsave() : mixed
- lindex() : mixed
- linsert() : mixed
- llen() : mixed
- lpop() : mixed
- lpush() : mixed
- lpushx() : mixed
- lrange() : mixed
- lrem() : mixed
- lset() : mixed
- ltrim() : mixed
- mget() : mixed
- migrate() : mixed
- monitor() : mixed
- move() : mixed
- mset() : mixed
- msetnx() : mixed
- multi() : mixed
- object() : mixed
- off() : bool
- Detaches an existing event handler from this component.
- on() : mixed
- Attaches an event handler to an event.
- open() : mixed
- Establishes a DB connection.
- persist() : mixed
- pexpire() : mixed
- pexpireat() : mixed
- pfadd() : mixed
- pfcount() : mixed
- pfmerge() : mixed
- ping() : mixed
- psetex() : mixed
- psubscribe() : mixed
- pttl() : mixed
- publish() : mixed
- pubsub() : mixed
- punsubscribe() : mixed
- quit() : mixed
- randomkey() : mixed
- readonly() : mixed
- readwrite() : mixed
- rename() : mixed
- renamenx() : mixed
- restore() : mixed
- role() : mixed
- rpop() : mixed
- rpoplpush() : mixed
- rpush() : mixed
- rpushx() : mixed
- sadd() : mixed
- save() : mixed
- scan() : mixed
- scard() : mixed
- scriptDebug() : mixed
- scriptExists() : mixed
- scriptFlush() : mixed
- scriptKill() : mixed
- scriptLoad() : mixed
- sdiff() : mixed
- sdiffstore() : mixed
- select() : mixed
- set() : mixed
- setbit() : mixed
- setex() : mixed
- setnx() : mixed
- setrange() : mixed
- shutdown() : mixed
- sinter() : mixed
- sinterstore() : mixed
- sismember() : mixed
- slaveof() : mixed
- slowlog() : mixed
- smembers() : mixed
- smove() : mixed
- sort() : mixed
- spop() : mixed
- srandmember() : mixed
- srem() : mixed
- sscan() : mixed
- strlen() : mixed
- subscribe() : mixed
- sunion() : mixed
- sunionstore() : mixed
- swapdb() : mixed
- sync() : mixed
- time() : mixed
- touch() : mixed
- trigger() : mixed
- Triggers an event.
- ttl() : mixed
- type() : mixed
- unlink() : mixed
- unsubscribe() : mixed
- unwatch() : mixed
- wait() : mixed
- watch() : mixed
- xack() : mixed
- xadd() : mixed
- xclaim() : mixed
- xdel() : mixed
- xgroup() : mixed
- xinfo() : mixed
- xlen() : mixed
- xpending() : mixed
- xrange() : mixed
- xread() : mixed
- xreadgroup() : mixed
- xrevrange() : mixed
- xtrim() : mixed
- zadd() : mixed
- zcard() : mixed
- zcount() : mixed
- zincrby() : mixed
- zinterstore() : mixed
- zlexcount() : mixed
- zrange() : mixed
- zrangebylex() : mixed
- zrangebyscore() : mixed
- zrank() : mixed
- zrem() : mixed
- zremrangebylex() : mixed
- zremrangebyrank() : mixed
- zremrangebyscore() : mixed
- zrevrange() : mixed
- zrevrangebylex() : mixed
- zrevrangebyscore() : mixed
- zrevrank() : mixed
- zscan() : mixed
- zscore() : mixed
- zunionstore() : mixed
- initConnection() : mixed
- Initializes the DB connection.
- sendRawCommand() : array<string|int, mixed>|bool|null|string
- Sends RAW command string to the server.
- attachBehaviorInternal() : Behavior
- Attaches a behavior to this component.
- isRedirect() : bool
- parseResponse() : mixed
- redirect() : mixed
Constants
EVENT_AFTER_OPEN
public
mixed
EVENT_AFTER_OPEN
= 'afterOpen'
Tags
Properties
$behaviors read-only
public
array<string|int, Behavior>
$behaviors
List of behaviors attached to this component.
$connectionString read-only
public
string
$connectionString
Socket connection string.
$connectionTimeout
public
float
$connectionTimeout
timeout to use for connection to redis. If not set the timeout set in php.ini will be used: ini_get("default_socket_timeout")
.
$contextOptions
public
array<string|int, mixed>
$contextOptions
= []
PHP context options which are used in the Redis connection stream.
Tags
$database
public
int
$database
= 0
the redis database to use. This is an integer value starting from 0. Defaults to 0.
Since version 2.0.6 you can disable the SELECT command sent after connection by setting this property to null
.
$dataTimeout
public
float
$dataTimeout
timeout to use for redis socket when reading and writing data. If not set the php default value will be used.
$driverName read-only
public
string
$driverName
Name of the DB driver.
$hostname
public
string
$hostname
= 'localhost'
the hostname or ip address to use for connecting to the redis server. Defaults to 'localhost'. If [[unixSocket]] is specified, hostname and [[port]] will be ignored.
$isActive read-only
public
bool
$isActive
Whether the DB connection is established.
$luaScriptBuilder read-only
public
LuaScriptBuilder
$luaScriptBuilder
$password
public
string
$password
the password for establishing DB connection. Defaults to null meaning no AUTH command is sent. See https://redis.io/commands/auth
$port
public
int
$port
= 6379
the port to use for connecting to the redis server. Default port is 6379. If [[unixSocket]] is specified, [[hostname]] and port will be ignored.
$redirectConnectionString
public
string
$redirectConnectionString
if the query gets redirected, use this as the temporary new hostname
Tags
$redisCommands
public
array<string|int, mixed>
$redisCommands
= [
'APPEND',
// Append a value to a key
'AUTH',
// Authenticate to the server
'BGREWRITEAOF',
// Asynchronously rewrite the append-only file
'BGSAVE',
// Asynchronously save the dataset to disk
'BITCOUNT',
// Count set bits in a string
'BITFIELD',
// Perform arbitrary bitfield integer operations on strings
'BITOP',
// Perform bitwise operations between strings
'BITPOS',
// Find first bit set or clear in a string
'BLPOP',
// Remove and get the first element in a list, or block until one is available
'BRPOP',
// Remove and get the last element in a list, or block until one is available
'BRPOPLPUSH',
// Pop a value from a list, push it to another list and return it; or block until one is available
'CLIENT KILL',
// Kill the connection of a client
'CLIENT LIST',
// Get the list of client connections
'CLIENT GETNAME',
// Get the current connection name
'CLIENT PAUSE',
// Stop processing commands from clients for some time
'CLIENT REPLY',
// Instruct the server whether to reply to commands
'CLIENT SETNAME',
// Set the current connection name
'CLUSTER ADDSLOTS',
// Assign new hash slots to receiving node
'CLUSTER COUNTKEYSINSLOT',
// Return the number of local keys in the specified hash slot
'CLUSTER DELSLOTS',
// Set hash slots as unbound in receiving node
'CLUSTER FAILOVER',
// Forces a slave to perform a manual failover of its master.
'CLUSTER FORGET',
// Remove a node from the nodes table
'CLUSTER GETKEYSINSLOT',
// Return local key names in the specified hash slot
'CLUSTER INFO',
// Provides info about Redis Cluster node state
'CLUSTER KEYSLOT',
// Returns the hash slot of the specified key
'CLUSTER MEET',
// Force a node cluster to handshake with another node
'CLUSTER NODES',
// Get Cluster config for the node
'CLUSTER REPLICATE',
// Reconfigure a node as a slave of the specified master node
'CLUSTER RESET',
// Reset a Redis Cluster node
'CLUSTER SAVECONFIG',
// Forces the node to save cluster state on disk
'CLUSTER SETSLOT',
// Bind a hash slot to a specific node
'CLUSTER SLAVES',
// List slave nodes of the specified master node
'CLUSTER SLOTS',
// Get array of Cluster slot to node mappings
'COMMAND',
// Get array of Redis command details
'COMMAND COUNT',
// Get total number of Redis commands
'COMMAND GETKEYS',
// Extract keys given a full Redis command
'COMMAND INFO',
// Get array of specific Redis command details
'CONFIG GET',
// Get the value of a configuration parameter
'CONFIG REWRITE',
// Rewrite the configuration file with the in memory configuration
'CONFIG SET',
// Set a configuration parameter to the given value
'CONFIG RESETSTAT',
// Reset the stats returned by INFO
'DBSIZE',
// Return the number of keys in the selected database
'DEBUG OBJECT',
// Get debugging information about a key
'DEBUG SEGFAULT',
// Make the server crash
'DECR',
// Decrement the integer value of a key by one
'DECRBY',
// Decrement the integer value of a key by the given number
'DEL',
// Delete a key
'DISCARD',
// Discard all commands issued after MULTI
'DUMP',
// Return a serialized version of the value stored at the specified key.
'ECHO',
// Echo the given string
'EVAL',
// Execute a Lua script server side
'EVALSHA',
// Execute a Lua script server side
'EXEC',
// Execute all commands issued after MULTI
'EXISTS',
// Determine if a key exists
'EXPIRE',
// Set a key's time to live in seconds
'EXPIREAT',
// Set the expiration for a key as a UNIX timestamp
'FLUSHALL',
// Remove all keys from all databases
'FLUSHDB',
// Remove all keys from the current database
'GEOADD',
// Add one or more geospatial items in the geospatial index represented using a sorted set
'GEOHASH',
// Returns members of a geospatial index as standard geohash strings
'GEOPOS',
// Returns longitude and latitude of members of a geospatial index
'GEODIST',
// Returns the distance between two members of a geospatial index
'GEORADIUS',
// Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point
'GEORADIUSBYMEMBER',
// Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member
'GET',
// Get the value of a key
'GETBIT',
// Returns the bit value at offset in the string value stored at key
'GETRANGE',
// Get a substring of the string stored at a key
'GETSET',
// Set the string value of a key and return its old value
'HDEL',
// Delete one or more hash fields
'HEXISTS',
// Determine if a hash field exists
'HGET',
// Get the value of a hash field
'HGETALL',
// Get all the fields and values in a hash
'HINCRBY',
// Increment the integer value of a hash field by the given number
'HINCRBYFLOAT',
// Increment the float value of a hash field by the given amount
'HKEYS',
// Get all the fields in a hash
'HLEN',
// Get the number of fields in a hash
'HMGET',
// Get the values of all the given hash fields
'HMSET',
// Set multiple hash fields to multiple values
'HSET',
// Set the string value of a hash field
'HSETNX',
// Set the value of a hash field, only if the field does not exist
'HSTRLEN',
// Get the length of the value of a hash field
'HVALS',
// Get all the values in a hash
'INCR',
// Increment the integer value of a key by one
'INCRBY',
// Increment the integer value of a key by the given amount
'INCRBYFLOAT',
// Increment the float value of a key by the given amount
'INFO',
// Get information and statistics about the server
'KEYS',
// Find all keys matching the given pattern
'LASTSAVE',
// Get the UNIX time stamp of the last successful save to disk
'LINDEX',
// Get an element from a list by its index
'LINSERT',
// Insert an element before or after another element in a list
'LLEN',
// Get the length of a list
'LPOP',
// Remove and get the first element in a list
'LPUSH',
// Prepend one or multiple values to a list
'LPUSHX',
// Prepend a value to a list, only if the list exists
'LRANGE',
// Get a range of elements from a list
'LREM',
// Remove elements from a list
'LSET',
// Set the value of an element in a list by its index
'LTRIM',
// Trim a list to the specified range
'MGET',
// Get the values of all the given keys
'MIGRATE',
// Atomically transfer a key from a Redis instance to another one.
'MONITOR',
// Listen for all requests received by the server in real time
'MOVE',
// Move a key to another database
'MSET',
// Set multiple keys to multiple values
'MSETNX',
// Set multiple keys to multiple values, only if none of the keys exist
'MULTI',
// Mark the start of a transaction block
'OBJECT',
// Inspect the internals of Redis objects
'PERSIST',
// Remove the expiration from a key
'PEXPIRE',
// Set a key's time to live in milliseconds
'PEXPIREAT',
// Set the expiration for a key as a UNIX timestamp specified in milliseconds
'PFADD',
// Adds the specified elements to the specified HyperLogLog.
'PFCOUNT',
// Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).
'PFMERGE',
// Merge N different HyperLogLogs into a single one.
'PING',
// Ping the server
'PSETEX',
// Set the value and expiration in milliseconds of a key
'PSUBSCRIBE',
// Listen for messages published to channels matching the given patterns
'PUBSUB',
// Inspect the state of the Pub/Sub subsystem
'PTTL',
// Get the time to live for a key in milliseconds
'PUBLISH',
// Post a message to a channel
'PUNSUBSCRIBE',
// Stop listening for messages posted to channels matching the given patterns
'QUIT',
// Close the connection
'RANDOMKEY',
// Return a random key from the keyspace
'READONLY',
// Enables read queries for a connection to a cluster slave node
'READWRITE',
// Disables read queries for a connection to a cluster slave node
'RENAME',
// Rename a key
'RENAMENX',
// Rename a key, only if the new key does not exist
'RESTORE',
// Create a key using the provided serialized value, previously obtained using DUMP.
'ROLE',
// Return the role of the instance in the context of replication
'RPOP',
// Remove and get the last element in a list
'RPOPLPUSH',
// Remove the last element in a list, prepend it to another list and return it
'RPUSH',
// Append one or multiple values to a list
'RPUSHX',
// Append a value to a list, only if the list exists
'SADD',
// Add one or more members to a set
'SAVE',
// Synchronously save the dataset to disk
'SCARD',
// Get the number of members in a set
'SCRIPT DEBUG',
// Set the debug mode for executed scripts.
'SCRIPT EXISTS',
// Check existence of scripts in the script cache.
'SCRIPT FLUSH',
// Remove all the scripts from the script cache.
'SCRIPT KILL',
// Kill the script currently in execution.
'SCRIPT LOAD',
// Load the specified Lua script into the script cache.
'SDIFF',
// Subtract multiple sets
'SDIFFSTORE',
// Subtract multiple sets and store the resulting set in a key
'SELECT',
// Change the selected database for the current connection
'SET',
// Set the string value of a key
'SETBIT',
// Sets or clears the bit at offset in the string value stored at key
'SETEX',
// Set the value and expiration of a key
'SETNX',
// Set the value of a key, only if the key does not exist
'SETRANGE',
// Overwrite part of a string at key starting at the specified offset
'SHUTDOWN',
// Synchronously save the dataset to disk and then shut down the server
'SINTER',
// Intersect multiple sets
'SINTERSTORE',
// Intersect multiple sets and store the resulting set in a key
'SISMEMBER',
// Determine if a given value is a member of a set
'SLAVEOF',
// Make the server a slave of another instance, or promote it as master
'SLOWLOG',
// Manages the Redis slow queries log
'SMEMBERS',
// Get all the members in a set
'SMOVE',
// Move a member from one set to another
'SORT',
// Sort the elements in a list, set or sorted set
'SPOP',
// Remove and return one or multiple random members from a set
'SRANDMEMBER',
// Get one or multiple random members from a set
'SREM',
// Remove one or more members from a set
'STRLEN',
// Get the length of the value stored in a key
'SUBSCRIBE',
// Listen for messages published to the given channels
'SUNION',
// Add multiple sets
'SUNIONSTORE',
// Add multiple sets and store the resulting set in a key
'SWAPDB',
// Swaps two Redis databases
'SYNC',
// Internal command used for replication
'TIME',
// Return the current server time
'TOUCH',
// Alters the last access time of a key(s). Returns the number of existing keys specified.
'TTL',
// Get the time to live for a key
'TYPE',
// Determine the type stored at key
'UNSUBSCRIBE',
// Stop listening for messages posted to the given channels
'UNLINK',
// Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.
'UNWATCH',
// Forget about all watched keys
'WAIT',
// Wait for the synchronous replication of all the write commands sent in the context of the current connection
'WATCH',
// Watch the given keys to determine execution of the MULTI/EXEC block
'XACK',
// Removes one or multiple messages from the pending entries list (PEL) of a stream consumer group
'XADD',
// Appends the specified stream entry to the stream at the specified key
'XCLAIM',
// Changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument
'XDEL',
// Removes the specified entries from a stream, and returns the number of entries deleted
'XGROUP',
// Manages the consumer groups associated with a stream data structure
'XINFO',
// Retrieves different information about the streams and associated consumer groups
'XLEN',
// Returns the number of entries inside a stream
'XPENDING',
// Fetching data from a stream via a consumer group, and not acknowledging such data, has the effect of creating pending entries
'XRANGE',
// Returns the stream entries matching a given range of IDs
'XREAD',
// Read data from one or multiple streams, only returning entries with an ID greater than the last received ID reported by the caller
'XREADGROUP',
// Special version of the XREAD command with support for consumer groups
'XREVRANGE',
// Exactly like XRANGE, but with the notable difference of returning the entries in reverse order, and also taking the start-end range in reverse order
'XTRIM',
// Trims the stream to a given number of items, evicting older items (items with lower IDs) if needed
'ZADD',
// Add one or more members to a sorted set, or update its score if it already exists
'ZCARD',
// Get the number of members in a sorted set
'ZCOUNT',
// Count the members in a sorted set with scores within the given values
'ZINCRBY',
// Increment the score of a member in a sorted set
'ZINTERSTORE',
// Intersect multiple sorted sets and store the resulting sorted set in a new key
'ZLEXCOUNT',
// Count the number of members in a sorted set between a given lexicographical range
'ZRANGE',
// Return a range of members in a sorted set, by index
'ZRANGEBYLEX',
// Return a range of members in a sorted set, by lexicographical range
'ZREVRANGEBYLEX',
// Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.
'ZRANGEBYSCORE',
// Return a range of members in a sorted set, by score
'ZRANK',
// Determine the index of a member in a sorted set
'ZREM',
// Remove one or more members from a sorted set
'ZREMRANGEBYLEX',
// Remove all members in a sorted set between the given lexicographical range
'ZREMRANGEBYRANK',
// Remove all members in a sorted set within the given indexes
'ZREMRANGEBYSCORE',
// Remove all members in a sorted set within the given scores
'ZREVRANGE',
// Return a range of members in a sorted set, by index, with scores ordered from high to low
'ZREVRANGEBYSCORE',
// Return a range of members in a sorted set, by score, with scores ordered from high to low
'ZREVRANK',
// Determine the index of a member in a sorted set, with scores ordered from high to low
'ZSCORE',
// Get the score associated with the given member in a sorted set
'ZUNIONSTORE',
// Add multiple sorted sets and store the resulting sorted set in a new key
'SCAN',
// Incrementally iterate the keys space
'SSCAN',
// Incrementally iterate Set elements
'HSCAN',
// Incrementally iterate hash fields and associated values
'ZSCAN',
]
List of available redis commands.
Tags
$retries
public
int
$retries
= 0
The number of times a command execution should be retried when a connection failure occurs. This is used in [[executeCommand()]] when a [[SocketException]] is thrown. Defaults to 0 meaning no retries on failure.
Tags
$retryInterval
public
int
$retryInterval
= 0
The retry interval in microseconds to wait between retry. This is used in [[executeCommand()]] when a [[SocketException]] is thrown. Defaults to 0 meaning no wait.
Tags
$scheme
public
string
$scheme
= 'tcp'
the connection scheme used for connecting to the redis server. Defaults to 'tcp'.
Tags
$socket read-only
public
resource|false
$socket
$socketClientFlags
public
int
$socketClientFlags
= STREAM_CLIENT_CONNECT
Bitmask field which may be set to any combination of connection flags passed to stream_socket_client().
Currently the select of connection flags is limited to STREAM_CLIENT_CONNECT
(default), STREAM_CLIENT_ASYNC_CONNECT
and STREAM_CLIENT_PERSISTENT
.
Warning:
STREAM_CLIENT_PERSISTENT
will make PHP reuse connections to the same server. If you are using multiple connection objects to refer to different redis [[$database|databases]] on the same [[port]], redis commands may get executed on the wrong database.STREAM_CLIENT_PERSISTENT
is only safe to use if you use only one database.You may still use persistent connections in this case when disambiguating ports as described in a comment on the PHP manual e.g. on the connection used for session storage, specify the port as:
'port' => '6379/session'
Tags
$unixSocket
public
string
$unixSocket
the unix socket path (e.g. /var/run/redis/redis.sock
) to use for connecting to the redis server.
This can be used instead of [[hostname]] and [[port]] to connect to the server using a unix socket.
If a unix socket path is specified, [[hostname]] and [[port]] will be ignored.
Tags
$username
public
string|null
$username
username for establishing DB connection. Defaults to null
meaning AUTH command will be performed without username.
Username was introduced in Redis 6.
Tags
$useSSL
public
bool
$useSSL
= false
Send sockets over SSL protocol. Default state is false.
Tags
$_behaviors
private
array<string|int, Behavior>|null
$_behaviors
the attached behaviors (behavior name => behavior). This is null
when not initialized.
$_events
private
array<string|int, mixed>
$_events
= []
the attached event handlers (event name => handlers)
$_eventWildcards
private
array<string|int, mixed>
$_eventWildcards
= []
the event handlers attached for wildcard patterns (event name wildcard => handlers)
Tags
$_pool
private
array<string|int, mixed>
$_pool
= []
redis redirect socket connection pool
Methods
__call()
Allows issuing all supported commands via magic methods.
public
__call(string $name, array<string|int, mixed> $params) : mixed
$redis->hmset('test_collection', 'key1', 'val1', 'key2', 'val2')
Parameters
- $name : string
-
name of the missing method to execute
- $params : array<string|int, mixed>
-
method call arguments
__clone()
This method is called after the object is created by cloning an existing one.
public
__clone() : mixed
It removes all behaviors because they are attached to the old object.
__construct()
Constructor.
public
__construct([array<string|int, mixed> $config = [] ]) : mixed
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call [[init()]].
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
Parameters
- $config : array<string|int, mixed> = []
-
name-value pairs that will be used to initialize the object properties
__get()
Returns the value of a component property.
public
__get(string $name) : mixed
This method will check in the following order and act accordingly:
- a property defined by a getter: return the getter result
- a property of a behavior: return the behavior property value
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $component->property;
.
Parameters
- $name : string
-
the property name
Tags
Return values
mixed —the property value or the value of a behavior's property
__isset()
Checks if a property is set, i.e. defined and not null.
public
__isset(string $name) : bool
This method will check in the following order and act accordingly:
- a property defined by a setter: return whether the property is set
- a property of a behavior: return whether the property is set
- return
false
for non existing properties
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($component->property)
.
Parameters
- $name : string
-
the property name or the event name
Tags
Return values
bool —whether the named property is set
__set()
Sets the value of a component property.
public
__set(string $name, mixed $value) : mixed
This method will check in the following order and act accordingly:
- a property defined by a setter: set the property value
- an event in the format of "on xyz": attach the handler to the event "xyz"
- a behavior in the format of "as xyz": attach the behavior named as "xyz"
- a property of a behavior: set the behavior property value
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $component->property = $value;
.
Parameters
- $name : string
-
the property name or the event name
- $value : mixed
-
the property value
Tags
__sleep()
Closes the connection when this component is being serialized.
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>__unset()
Sets a component property to be null.
public
__unset(string $name) : mixed
This method will check in the following order and act accordingly:
- a property defined by a setter: set the property value to be null
- a property of a behavior: set the property value to be null
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($component->property)
.
Parameters
- $name : string
-
the property name
Tags
append()
public
append([mixed $key = ][, mixed $value = ]) : mixed
Append a value to a key. https://redis.io/commands/append
Parameters
- $key : mixed =
- $value : mixed =
attachBehavior()
Attaches a behavior to this component.
public
attachBehavior(string $name, string|array<string|int, mixed>|Behavior $behavior) : Behavior
This method will create the behavior object based on the given configuration. After that, the behavior object will be attached to this component by calling the [[Behavior::attach()]] method.
Parameters
- $name : string
-
the name of the behavior.
- $behavior : string|array<string|int, mixed>|Behavior
-
the behavior configuration. This can be one of the following:
- a [[Behavior]] object
- a string specifying the behavior class
- an object configuration array that will be passed to [[Yii::createObject()]] to create the behavior object.
Tags
Return values
Behavior —the behavior object
attachBehaviors()
Attaches a list of behaviors to the component.
public
attachBehaviors(array<string|int, mixed> $behaviors) : mixed
Each behavior is indexed by its name and should be a [[Behavior]] object, a string specifying the behavior class, or an configuration array for creating the behavior.
Parameters
- $behaviors : array<string|int, mixed>
-
list of behaviors to be attached to the component
Tags
auth()
public
auth([mixed $password = ]) : mixed
Authenticate to the server. https://redis.io/commands/auth
Parameters
- $password : mixed =
behaviors()
Returns a list of behaviors that this component should behave as.
public
behaviors() : array<string|int, mixed>
Child classes may override this method to specify the behaviors they want to behave as.
The return value of this method should be an array of behavior objects or configurations indexed by behavior names. A behavior configuration can be either a string specifying the behavior class or an array of the following structure:
'behaviorName' => [
'class' => 'BehaviorClass',
'property1' => 'value1',
'property2' => 'value2',
]
Note that a behavior class must extend from [[Behavior]]. Behaviors can be attached using a name or anonymously. When a name is used as the array key, using this name, the behavior can later be retrieved using [[getBehavior()]] or be detached using [[detachBehavior()]]. Anonymous behaviors can not be retrieved or detached.
Behaviors declared in this method will be attached to the component automatically (on demand).
Return values
array<string|int, mixed> —the behavior configurations.
bgrewriteaof()
public
bgrewriteaof() : mixed
Asynchronously rewrite the append-only file. https://redis.io/commands/bgrewriteaof
bgsave()
public
bgsave() : mixed
Asynchronously save the dataset to disk. https://redis.io/commands/bgsave
bitcount()
public
bitcount([mixed $key = ][, mixed $start = null ][, mixed $end = null ]) : mixed
Count set bits in a string. https://redis.io/commands/bitcount
Parameters
- $key : mixed =
- $start : mixed = null
- $end : mixed = null
bitfield()
public
bitfield([mixed $key = ][, mixed ...$operations = ]) : mixed
Perform arbitrary bitfield integer operations on strings. https://redis.io/commands/bitfield
Parameters
- $key : mixed =
- $operations : mixed =
bitop()
public
bitop([mixed $operation = ][, mixed $destkey = ][, mixed ...$keys = ]) : mixed
Perform bitwise operations between strings. https://redis.io/commands/bitop
Parameters
- $operation : mixed =
- $destkey : mixed =
- $keys : mixed =
bitpos()
public
bitpos([mixed $key = ][, mixed $bit = ][, mixed $start = null ][, mixed $end = null ]) : mixed
Find first bit set or clear in a string. https://redis.io/commands/bitpos
Parameters
- $key : mixed =
- $bit : mixed =
- $start : mixed = null
- $end : mixed = null
blpop()
public
blpop([mixed ...$keys = ][, mixed $timeout = ]) : mixed
Remove and get the first element in a list, or block until one is available. https://redis.io/commands/blpop
Parameters
- $keys : mixed =
- $timeout : mixed =
brpop()
public
brpop([mixed ...$keys = ][, mixed $timeout = ]) : mixed
Remove and get the last element in a list, or block until one is available. https://redis.io/commands/brpop
Parameters
- $keys : mixed =
- $timeout : mixed =
brpoplpush()
public
brpoplpush([mixed $source = ][, mixed $destination = ][, mixed $timeout = ]) : mixed
Pop a value from a list, push it to another list and return it; or block until one is available. https://redis.io/commands/brpoplpush
Parameters
- $source : mixed =
- $destination : mixed =
- $timeout : mixed =
canGetProperty()
Returns a value indicating whether a property can be read.
public
canGetProperty(string $name[, bool $checkVars = true ][, bool $checkBehaviors = true ]) : bool
A property can be read if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true); - an attached behavior has a readable property of the given name (when
$checkBehaviors
is true).
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
- $checkBehaviors : bool = true
-
whether to treat behaviors' properties as properties of this component
Tags
Return values
bool —whether the property can be read
canSetProperty()
Returns a value indicating whether a property can be set.
public
canSetProperty(string $name[, bool $checkVars = true ][, bool $checkBehaviors = true ]) : bool
A property can be written if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true); - an attached behavior has a writable property of the given name (when
$checkBehaviors
is true).
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
- $checkBehaviors : bool = true
-
whether to treat behaviors' properties as properties of this component
Tags
Return values
bool —whether the property can be written
className()
Returns the fully qualified name of this class.
public
static className() : string
Tags
Return values
string —the fully qualified name of this class.
clientGetname()
public
clientGetname() : mixed
Get the current connection name. https://redis.io/commands/client-getname
clientKill()
public
clientKill([mixed ...$filters = ]) : mixed
Kill the connection of a client. https://redis.io/commands/client-kill
Parameters
- $filters : mixed =
clientList()
public
clientList() : mixed
Get the list of client connections. https://redis.io/commands/client-list
clientPause()
public
clientPause([mixed $timeout = ]) : mixed
Stop processing commands from clients for some time. https://redis.io/commands/client-pause
Parameters
- $timeout : mixed =
clientReply()
public
clientReply([mixed $option = ]) : mixed
Instruct the server whether to reply to commands. https://redis.io/commands/client-reply
Parameters
- $option : mixed =
clientSetname()
public
clientSetname([mixed $connectionName = ]) : mixed
Set the current connection name. https://redis.io/commands/client-setname
Parameters
- $connectionName : mixed =
close()
Closes the currently active DB connection.
public
close() : mixed
It does nothing if the connection is already closed.
clusterAddslots()
public
clusterAddslots([mixed ...$slots = ]) : mixed
Assign new hash slots to receiving node. https://redis.io/commands/cluster-addslots
Parameters
- $slots : mixed =
clusterCountkeysinslot()
public
clusterCountkeysinslot([mixed $slot = ]) : mixed
Return the number of local keys in the specified hash slot. https://redis.io/commands/cluster-countkeysinslot
Parameters
- $slot : mixed =
clusterDelslots()
public
clusterDelslots([mixed ...$slots = ]) : mixed
Set hash slots as unbound in receiving node. https://redis.io/commands/cluster-delslots
Parameters
- $slots : mixed =
clusterFailover()
public
clusterFailover([mixed $option = null ]) : mixed
Forces a slave to perform a manual failover of its master.. https://redis.io/commands/cluster-failover
Parameters
- $option : mixed = null
clusterForget()
public
clusterForget([mixed $nodeId = ]) : mixed
Remove a node from the nodes table. https://redis.io/commands/cluster-forget
Parameters
- $nodeId : mixed =
clusterGetkeysinslot()
public
clusterGetkeysinslot([mixed $slot = ][, mixed $count = ]) : mixed
Return local key names in the specified hash slot. https://redis.io/commands/cluster-getkeysinslot
Parameters
- $slot : mixed =
- $count : mixed =
clusterInfo()
public
clusterInfo() : mixed
Provides info about Redis Cluster node state. https://redis.io/commands/cluster-info
clusterKeyslot()
public
clusterKeyslot([mixed $key = ]) : mixed
Returns the hash slot of the specified key. https://redis.io/commands/cluster-keyslot
Parameters
- $key : mixed =
clusterMeet()
public
clusterMeet([mixed $ip = ][, mixed $port = ]) : mixed
Force a node cluster to handshake with another node. https://redis.io/commands/cluster-meet
Parameters
- $ip : mixed =
- $port : mixed =
clusterNodes()
public
clusterNodes() : mixed
Get Cluster config for the node. https://redis.io/commands/cluster-nodes
clusterReplicate()
public
clusterReplicate([mixed $nodeId = ]) : mixed
Reconfigure a node as a slave of the specified master node. https://redis.io/commands/cluster-replicate
Parameters
- $nodeId : mixed =
clusterReset()
public
clusterReset([mixed $resetType = "\"SOFT\"" ]) : mixed
Reset a Redis Cluster node. https://redis.io/commands/cluster-reset
Parameters
- $resetType : mixed = "\"SOFT\""
clusterSaveconfig()
public
clusterSaveconfig() : mixed
Forces the node to save cluster state on disk. https://redis.io/commands/cluster-saveconfig
clusterSetslot()
public
clusterSetslot([mixed $slot = ][, mixed $type = ][, mixed $nodeid = null ]) : mixed
Bind a hash slot to a specific node. https://redis.io/commands/cluster-setslot
Parameters
- $slot : mixed =
- $type : mixed =
- $nodeid : mixed = null
clusterSlaves()
public
clusterSlaves([mixed $nodeId = ]) : mixed
List slave nodes of the specified master node. https://redis.io/commands/cluster-slaves
Parameters
- $nodeId : mixed =
clusterSlots()
public
clusterSlots() : mixed
Get array of Cluster slot to node mappings. https://redis.io/commands/cluster-slots
command()
public
command() : mixed
Get array of Redis command details. https://redis.io/commands/command
commandCount()
public
commandCount() : mixed
Get total number of Redis commands. https://redis.io/commands/command-count
commandGetkeys()
public
commandGetkeys() : mixed
Extract keys given a full Redis command. https://redis.io/commands/command-getkeys
commandInfo()
public
commandInfo([mixed ...$commandNames = ]) : mixed
Get array of specific Redis command details. https://redis.io/commands/command-info
Parameters
- $commandNames : mixed =
configGet()
public
configGet([mixed $parameter = ]) : mixed
Get the value of a configuration parameter. https://redis.io/commands/config-get
Parameters
- $parameter : mixed =
configResetstat()
public
configResetstat() : mixed
Reset the stats returned by INFO. https://redis.io/commands/config-resetstat
configRewrite()
public
configRewrite() : mixed
Rewrite the configuration file with the in memory configuration. https://redis.io/commands/config-rewrite
configSet()
public
configSet([mixed $parameter = ][, mixed $value = ]) : mixed
Set a configuration parameter to the given value. https://redis.io/commands/config-set
Parameters
- $parameter : mixed =
- $value : mixed =
dbsize()
public
dbsize() : mixed
Return the number of keys in the selected database. https://redis.io/commands/dbsize
debugObject()
public
debugObject([mixed $key = ]) : mixed
Get debugging information about a key. https://redis.io/commands/debug-object
Parameters
- $key : mixed =
debugSegfault()
public
debugSegfault() : mixed
Make the server crash. https://redis.io/commands/debug-segfault
decr()
public
decr([mixed $key = ]) : mixed
Decrement the integer value of a key by one. https://redis.io/commands/decr
Parameters
- $key : mixed =
decrby()
public
decrby([mixed $key = ][, mixed $decrement = ]) : mixed
Decrement the integer value of a key by the given number. https://redis.io/commands/decrby
Parameters
- $key : mixed =
- $decrement : mixed =
del()
public
del([mixed ...$keys = ]) : mixed
Delete a key. https://redis.io/commands/del
Parameters
- $keys : mixed =
detachBehavior()
Detaches a behavior from the component.
public
detachBehavior(string $name) : Behavior|null
The behavior's [[Behavior::detach()]] method will be invoked.
Parameters
- $name : string
-
the behavior's name.
Return values
Behavior|null —the detached behavior. Null if the behavior does not exist.
detachBehaviors()
Detaches all behaviors from the component.
public
detachBehaviors() : mixed
discard()
public
discard() : mixed
Discard all commands issued after MULTI. https://redis.io/commands/discard
dump()
public
dump([mixed $key = ]) : mixed
Return a serialized version of the value stored at the specified key.. https://redis.io/commands/dump
Parameters
- $key : mixed =
echo()
public
echo([mixed $message = ]) : mixed
Echo the given string. https://redis.io/commands/echo
Parameters
- $message : mixed =
ensureBehaviors()
Makes sure that the behaviors declared in [[behaviors()]] are attached to this component.
public
ensureBehaviors() : mixed
eval()
public
eval([mixed $script = ][, mixed $numkeys = ][, mixed ...$keys = ][, mixed ...$args = ]) : mixed
Execute a Lua script server side. https://redis.io/commands/eval
Parameters
- $script : mixed =
- $numkeys : mixed =
- $keys : mixed =
- $args : mixed =
evalsha()
public
evalsha([mixed $sha1 = ][, mixed $numkeys = ][, mixed ...$keys = ][, mixed ...$args = ]) : mixed
Execute a Lua script server side. https://redis.io/commands/evalsha
Parameters
- $sha1 : mixed =
- $numkeys : mixed =
- $keys : mixed =
- $args : mixed =
exec()
public
exec() : mixed
Execute all commands issued after MULTI. https://redis.io/commands/exec
executeCommand()
Executes a redis command.
public
executeCommand(string $name[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>|bool|null|string
For a list of available commands and their parameters see https://redis.io/commands.
The params array should contain the params separated by white space, e.g. to execute
SET mykey somevalue NX
call the following:
$redis->executeCommand('SET', ['mykey', 'somevalue', 'NX']);
Parameters
- $name : string
-
the name of the command
- $params : array<string|int, mixed> = []
-
list of parameters for the command
Tags
Return values
array<string|int, mixed>|bool|null|string —Dependent on the executed command this method will return different data types:
-
true
for commands that return "status reply" with the message'OK'
or'PONG'
. -
string
for commands that return "status reply" that does not have the messageOK
(since version 2.0.1). -
string
for commands that return "integer reply" as the value is in the range of a signed 64 bit integer. -
string
ornull
for commands that return "bulk reply". -
array
for commands that return "Multi-bulk replies".
See redis protocol description for details on the mentioned reply types.
exists()
public
exists([mixed ...$keys = ]) : mixed
Determine if a key exists. https://redis.io/commands/exists
Parameters
- $keys : mixed =
expire()
public
expire([mixed $key = ][, mixed $seconds = ]) : mixed
Set a key's time to live in seconds. https://redis.io/commands/expire
Parameters
- $key : mixed =
- $seconds : mixed =
expireat()
public
expireat([mixed $key = ][, mixed $timestamp = ]) : mixed
Set the expiration for a key as a UNIX timestamp. https://redis.io/commands/expireat
Parameters
- $key : mixed =
- $timestamp : mixed =
flushall()
public
flushall([mixed $ASYNC = null ]) : mixed
Remove all keys from all databases. https://redis.io/commands/flushall
Parameters
- $ASYNC : mixed = null
flushdb()
public
flushdb([mixed $ASYNC = null ]) : mixed
Remove all keys from the current database. https://redis.io/commands/flushdb
Parameters
- $ASYNC : mixed = null
geoadd()
public
geoadd([mixed $key = ][, mixed $longitude = ][, mixed $latitude = ][, mixed $member = ][, mixed ...$more = ]) : mixed
Add one or more geospatial items in the geospatial index represented using a sorted set. https://redis.io/commands/geoadd
Parameters
- $key : mixed =
- $longitude : mixed =
- $latitude : mixed =
- $member : mixed =
- $more : mixed =
geodist()
public
geodist([mixed $key = ][, mixed $member1 = ][, mixed $member2 = ][, mixed $unit = null ]) : mixed
Returns the distance between two members of a geospatial index. https://redis.io/commands/geodist
Parameters
- $key : mixed =
- $member1 : mixed =
- $member2 : mixed =
- $unit : mixed = null
geohash()
public
geohash([mixed $key = ][, mixed ...$members = ]) : mixed
Returns members of a geospatial index as standard geohash strings. https://redis.io/commands/geohash
Parameters
- $key : mixed =
- $members : mixed =
geopos()
public
geopos([mixed $key = ][, mixed ...$members = ]) : mixed
Returns longitude and latitude of members of a geospatial index. https://redis.io/commands/geopos
Parameters
- $key : mixed =
- $members : mixed =
georadius()
public
georadius([mixed $key = ][, mixed $longitude = ][, mixed $latitude = ][, mixed $radius = ][, mixed $metric = ][, mixed ...$options = ]) : mixed
Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a point. https://redis.io/commands/georadius
Parameters
- $key : mixed =
- $longitude : mixed =
- $latitude : mixed =
- $radius : mixed =
- $metric : mixed =
- $options : mixed =
georadiusbymember()
public
georadiusbymember([mixed $key = ][, mixed $member = ][, mixed $radius = ][, mixed $metric = ][, mixed ...$options = ]) : mixed
Query a sorted set representing a geospatial index to fetch members matching a given maximum distance from a member. https://redis.io/commands/georadiusbymember
Parameters
- $key : mixed =
- $member : mixed =
- $radius : mixed =
- $metric : mixed =
- $options : mixed =
get()
public
get([mixed $key = ]) : mixed
Get the value of a key. https://redis.io/commands/get
Parameters
- $key : mixed =
getBehavior()
Returns the named behavior object.
public
getBehavior(string $name) : Behavior|null
Parameters
- $name : string
-
the behavior name
Return values
Behavior|null —the behavior object, or null if the behavior does not exist
getBehaviors()
Returns all behaviors attached to this component.
public
getBehaviors() : array<string|int, Behavior>
Return values
array<string|int, Behavior> —list of behaviors attached to this component
getbit()
public
getbit([mixed $key = ][, mixed $offset = ]) : mixed
Returns the bit value at offset in the string value stored at key. https://redis.io/commands/getbit
Parameters
- $key : mixed =
- $offset : mixed =
getConnectionString()
Return the connection string used to open a socket connection. During a redirect (cluster mode) this will be the target of the redirect.
public
getConnectionString() : string
Tags
Return values
string —socket connection string
getDriverName()
Returns the name of the DB driver for the current [[dsn]].
public
getDriverName() : string
Return values
string —name of the DB driver
getIsActive()
Returns a value indicating whether the DB connection is established.
public
getIsActive() : bool
Return values
bool —whether the DB connection is established
getLuaScriptBuilder()
public
getLuaScriptBuilder() : LuaScriptBuilder
Return values
LuaScriptBuildergetrange()
public
getrange([mixed $key = ][, mixed $start = ][, mixed $end = ]) : mixed
Get a substring of the string stored at a key. https://redis.io/commands/getrange
Parameters
- $key : mixed =
- $start : mixed =
- $end : mixed =
getset()
public
getset([mixed $key = ][, mixed $value = ]) : mixed
Set the string value of a key and return its old value. https://redis.io/commands/getset
Parameters
- $key : mixed =
- $value : mixed =
getSocket()
Return the connection resource if a connection to the target has been established before, `false` otherwise.
public
getSocket() : resource|false
Return values
resource|falsehasEventHandlers()
Returns a value indicating whether there is any handler attached to the named event.
public
hasEventHandlers(string $name) : bool
Parameters
- $name : string
-
the event name
Return values
bool —whether there is any handler attached to the event.
hasMethod()
Returns a value indicating whether a method is defined.
public
hasMethod(string $name[, bool $checkBehaviors = true ]) : bool
A method is defined if:
- the class has a method with the specified name
- an attached behavior has a method with the given name (when
$checkBehaviors
is true).
Parameters
- $name : string
-
the property name
- $checkBehaviors : bool = true
-
whether to treat behaviors' methods as methods of this component
Return values
bool —whether the method is defined
hasProperty()
Returns a value indicating whether a property is defined for this component.
public
hasProperty(string $name[, bool $checkVars = true ][, bool $checkBehaviors = true ]) : bool
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true); - an attached behavior has a property of the given name (when
$checkBehaviors
is true).
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
- $checkBehaviors : bool = true
-
whether to treat behaviors' properties as properties of this component
Tags
Return values
bool —whether the property is defined
hdel()
public
hdel([mixed $key = ][, mixed ...$fields = ]) : mixed
Delete one or more hash fields. https://redis.io/commands/hdel
Parameters
- $key : mixed =
- $fields : mixed =
hexists()
public
hexists([mixed $key = ][, mixed $field = ]) : mixed
Determine if a hash field exists. https://redis.io/commands/hexists
Parameters
- $key : mixed =
- $field : mixed =
hget()
public
hget([mixed $key = ][, mixed $field = ]) : mixed
Get the value of a hash field. https://redis.io/commands/hget
Parameters
- $key : mixed =
- $field : mixed =
hgetall()
public
hgetall([mixed $key = ]) : mixed
Get all the fields and values in a hash. https://redis.io/commands/hgetall
Parameters
- $key : mixed =
hincrby()
public
hincrby([mixed $key = ][, mixed $field = ][, mixed $increment = ]) : mixed
Increment the integer value of a hash field by the given number. https://redis.io/commands/hincrby
Parameters
- $key : mixed =
- $field : mixed =
- $increment : mixed =
hincrbyfloat()
public
hincrbyfloat([mixed $key = ][, mixed $field = ][, mixed $increment = ]) : mixed
Increment the float value of a hash field by the given amount. https://redis.io/commands/hincrbyfloat
Parameters
- $key : mixed =
- $field : mixed =
- $increment : mixed =
hkeys()
public
hkeys([mixed $key = ]) : mixed
Get all the fields in a hash. https://redis.io/commands/hkeys
Parameters
- $key : mixed =
hlen()
public
hlen([mixed $key = ]) : mixed
Get the number of fields in a hash. https://redis.io/commands/hlen
Parameters
- $key : mixed =
hmget()
public
hmget([mixed $key = ][, mixed ...$fields = ]) : mixed
Get the values of all the given hash fields. https://redis.io/commands/hmget
Parameters
- $key : mixed =
- $fields : mixed =
hmset()
public
hmset([mixed $key = ][, mixed $field = ][, mixed $value = ][, mixed ...$more = ]) : mixed
Set multiple hash fields to multiple values. https://redis.io/commands/hmset
Parameters
- $key : mixed =
- $field : mixed =
- $value : mixed =
- $more : mixed =
hscan()
public
hscan([mixed $key = ][, mixed $cursor = ][, mixed $MATCH = null ][, mixed $pattern = null ][, mixed $COUNT = null ][, mixed $count = null ]) : mixed
Incrementally iterate hash fields and associated values. https://redis.io/commands/hscan
Parameters
- $key : mixed =
- $cursor : mixed =
- $MATCH : mixed = null
- $pattern : mixed = null
- $COUNT : mixed = null
- $count : mixed = null
hset()
public
hset([mixed $key = ][, mixed $field = ][, mixed $value = ]) : mixed
Set the string value of a hash field. https://redis.io/commands/hset
Parameters
- $key : mixed =
- $field : mixed =
- $value : mixed =
hsetnx()
public
hsetnx([mixed $key = ][, mixed $field = ][, mixed $value = ]) : mixed
Set the value of a hash field, only if the field does not exist. https://redis.io/commands/hsetnx
Parameters
- $key : mixed =
- $field : mixed =
- $value : mixed =
hstrlen()
public
hstrlen([mixed $key = ][, mixed $field = ]) : mixed
Get the length of the value of a hash field. https://redis.io/commands/hstrlen
Parameters
- $key : mixed =
- $field : mixed =
hvals()
public
hvals([mixed $key = ]) : mixed
Get all the values in a hash. https://redis.io/commands/hvals
Parameters
- $key : mixed =
incr()
public
incr([mixed $key = ]) : mixed
Increment the integer value of a key by one. https://redis.io/commands/incr
Parameters
- $key : mixed =
incrby()
public
incrby([mixed $key = ][, mixed $increment = ]) : mixed
Increment the integer value of a key by the given amount. https://redis.io/commands/incrby
Parameters
- $key : mixed =
- $increment : mixed =
incrbyfloat()
public
incrbyfloat([mixed $key = ][, mixed $increment = ]) : mixed
Increment the float value of a key by the given amount. https://redis.io/commands/incrbyfloat
Parameters
- $key : mixed =
- $increment : mixed =
info()
public
info([mixed $section = null ]) : mixed
Get information and statistics about the server. https://redis.io/commands/info
Parameters
- $section : mixed = null
init()
Initializes the object.
public
init() : mixed
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
keys()
public
keys([mixed $pattern = ]) : mixed
Find all keys matching the given pattern. https://redis.io/commands/keys
Parameters
- $pattern : mixed =
lastsave()
public
lastsave() : mixed
Get the UNIX time stamp of the last successful save to disk. https://redis.io/commands/lastsave
lindex()
public
lindex([mixed $key = ][, mixed $index = ]) : mixed
Get an element from a list by its index. https://redis.io/commands/lindex
Parameters
- $key : mixed =
- $index : mixed =
linsert()
public
linsert([mixed $key = ][, mixed $where = ][, mixed $pivot = ][, mixed $value = ]) : mixed
Insert an element before or after another element in a list. https://redis.io/commands/linsert
Parameters
- $key : mixed =
- $where : mixed =
- $pivot : mixed =
- $value : mixed =
llen()
public
llen([mixed $key = ]) : mixed
Get the length of a list. https://redis.io/commands/llen
Parameters
- $key : mixed =
lpop()
public
lpop([mixed $key = ]) : mixed
Remove and get the first element in a list. https://redis.io/commands/lpop
Parameters
- $key : mixed =
lpush()
public
lpush([mixed $key = ][, mixed ...$values = ]) : mixed
Prepend one or multiple values to a list. https://redis.io/commands/lpush
Parameters
- $key : mixed =
- $values : mixed =
lpushx()
public
lpushx([mixed $key = ][, mixed $value = ]) : mixed
Prepend a value to a list, only if the list exists. https://redis.io/commands/lpushx
Parameters
- $key : mixed =
- $value : mixed =
lrange()
public
lrange([mixed $key = ][, mixed $start = ][, mixed $stop = ]) : mixed
Get a range of elements from a list. https://redis.io/commands/lrange
Parameters
- $key : mixed =
- $start : mixed =
- $stop : mixed =
lrem()
public
lrem([mixed $key = ][, mixed $count = ][, mixed $value = ]) : mixed
Remove elements from a list. https://redis.io/commands/lrem
Parameters
- $key : mixed =
- $count : mixed =
- $value : mixed =
lset()
public
lset([mixed $key = ][, mixed $index = ][, mixed $value = ]) : mixed
Set the value of an element in a list by its index. https://redis.io/commands/lset
Parameters
- $key : mixed =
- $index : mixed =
- $value : mixed =
ltrim()
public
ltrim([mixed $key = ][, mixed $start = ][, mixed $stop = ]) : mixed
Trim a list to the specified range. https://redis.io/commands/ltrim
Parameters
- $key : mixed =
- $start : mixed =
- $stop : mixed =
mget()
public
mget([mixed ...$keys = ]) : mixed
Get the values of all the given keys. https://redis.io/commands/mget
Parameters
- $keys : mixed =
migrate()
public
migrate([mixed $host = ][, mixed $port = ][, mixed $key = ][, mixed $destinationDb = ][, mixed $timeout = ][, mixed ...$options = ]) : mixed
Atomically transfer a key from a Redis instance to another one.. https://redis.io/commands/migrate
Parameters
- $host : mixed =
- $port : mixed =
- $key : mixed =
- $destinationDb : mixed =
- $timeout : mixed =
- $options : mixed =
monitor()
public
monitor() : mixed
Listen for all requests received by the server in real time. https://redis.io/commands/monitor
move()
public
move([mixed $key = ][, mixed $db = ]) : mixed
Move a key to another database. https://redis.io/commands/move
Parameters
- $key : mixed =
- $db : mixed =
mset()
public
mset([mixed ...$keyValuePairs = ]) : mixed
Set multiple keys to multiple values. https://redis.io/commands/mset
Parameters
- $keyValuePairs : mixed =
msetnx()
public
msetnx([mixed ...$keyValuePairs = ]) : mixed
Set multiple keys to multiple values, only if none of the keys exist. https://redis.io/commands/msetnx
Parameters
- $keyValuePairs : mixed =
multi()
public
multi() : mixed
Mark the start of a transaction block. https://redis.io/commands/multi
object()
public
object([mixed $subcommand = ][, mixed ...$argumentss = ]) : mixed
Inspect the internals of Redis objects. https://redis.io/commands/object
Parameters
- $subcommand : mixed =
- $argumentss : mixed =
off()
Detaches an existing event handler from this component.
public
off(string $name[, callable|null $handler = null ]) : bool
This method is the opposite of [[on()]].
Note: in case wildcard pattern is passed for event name, only the handlers registered with this wildcard will be removed, while handlers registered with plain names matching this wildcard will remain.
Parameters
- $name : string
-
event name
- $handler : callable|null = null
-
the event handler to be removed. If it is null, all handlers attached to the named event will be removed.
Tags
Return values
bool —if a handler is found and detached
on()
Attaches an event handler to an event.
public
on(string $name, callable $handler[, mixed $data = null ][, bool $append = true ]) : mixed
The event handler must be a valid PHP callback. The following are some examples:
function ($event) { ... } // anonymous function
[$object, 'handleClick'] // $object->handleClick()
['Page', 'handleClick'] // Page::handleClick()
'handleClick' // global function handleClick()
The event handler must be defined with the following signature,
function ($event)
where $event
is an [[Event]] object which includes parameters associated with the event.
Since 2.0.14 you can specify event name as a wildcard pattern:
$component->on('event.group.*', function ($event) {
Yii::trace($event->name . ' is triggered.');
});
Parameters
- $name : string
-
the event name
- $handler : callable
-
the event handler
- $data : mixed = null
-
the data to be passed to the event handler when the event is triggered. When the event handler is invoked, this data can be accessed via [[Event::data]].
- $append : bool = true
-
whether to append new event handler to the end of the existing handler list. If false, the new handler will be inserted at the beginning of the existing handler list.
Tags
open()
Establishes a DB connection.
public
open() : mixed
It does nothing if a DB connection has already been established.
Tags
persist()
public
persist([mixed $key = ]) : mixed
Remove the expiration from a key. https://redis.io/commands/persist
Parameters
- $key : mixed =
pexpire()
public
pexpire([mixed $key = ][, mixed $milliseconds = ]) : mixed
Set a key's time to live in milliseconds. https://redis.io/commands/pexpire
Parameters
- $key : mixed =
- $milliseconds : mixed =
pexpireat()
public
pexpireat([mixed $key = ][, mixed $millisecondsTimestamp = ]) : mixed
Set the expiration for a key as a UNIX timestamp specified in milliseconds. https://redis.io/commands/pexpireat
Parameters
- $key : mixed =
- $millisecondsTimestamp : mixed =
pfadd()
public
pfadd([mixed $key = ][, mixed ...$elements = ]) : mixed
Adds the specified elements to the specified HyperLogLog.. https://redis.io/commands/pfadd
Parameters
- $key : mixed =
- $elements : mixed =
pfcount()
public
pfcount([mixed ...$keys = ]) : mixed
Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s).. https://redis.io/commands/pfcount
Parameters
- $keys : mixed =
pfmerge()
public
pfmerge([mixed $destkey = ][, mixed ...$sourcekeys = ]) : mixed
Merge N different HyperLogLogs into a single one.. https://redis.io/commands/pfmerge
Parameters
- $destkey : mixed =
- $sourcekeys : mixed =
ping()
public
ping([mixed $message = null ]) : mixed
Ping the server. https://redis.io/commands/ping
Parameters
- $message : mixed = null
psetex()
public
psetex([mixed $key = ][, mixed $milliseconds = ][, mixed $value = ]) : mixed
Set the value and expiration in milliseconds of a key. https://redis.io/commands/psetex
Parameters
- $key : mixed =
- $milliseconds : mixed =
- $value : mixed =
psubscribe()
public
psubscribe([mixed ...$patterns = ]) : mixed
Listen for messages published to channels matching the given patterns. https://redis.io/commands/psubscribe
Parameters
- $patterns : mixed =
pttl()
public
pttl([mixed $key = ]) : mixed
Get the time to live for a key in milliseconds. https://redis.io/commands/pttl
Parameters
- $key : mixed =
publish()
public
publish([mixed $channel = ][, mixed $message = ]) : mixed
Post a message to a channel. https://redis.io/commands/publish
Parameters
- $channel : mixed =
- $message : mixed =
pubsub()
public
pubsub([mixed $subcommand = ][, mixed ...$arguments = ]) : mixed
Inspect the state of the Pub/Sub subsystem. https://redis.io/commands/pubsub
Parameters
- $subcommand : mixed =
- $arguments : mixed =
punsubscribe()
public
punsubscribe([mixed ...$patterns = ]) : mixed
Stop listening for messages posted to channels matching the given patterns. https://redis.io/commands/punsubscribe
Parameters
- $patterns : mixed =
quit()
public
quit() : mixed
Close the connection. https://redis.io/commands/quit
randomkey()
public
randomkey() : mixed
Return a random key from the keyspace. https://redis.io/commands/randomkey
readonly()
public
readonly() : mixed
Enables read queries for a connection to a cluster slave node. https://redis.io/commands/readonly
readwrite()
public
readwrite() : mixed
Disables read queries for a connection to a cluster slave node. https://redis.io/commands/readwrite
rename()
public
rename([mixed $key = ][, mixed $newkey = ]) : mixed
Rename a key. https://redis.io/commands/rename
Parameters
- $key : mixed =
- $newkey : mixed =
renamenx()
public
renamenx([mixed $key = ][, mixed $newkey = ]) : mixed
Rename a key, only if the new key does not exist. https://redis.io/commands/renamenx
Parameters
- $key : mixed =
- $newkey : mixed =
restore()
public
restore([mixed $key = ][, mixed $ttl = ][, mixed $serializedValue = ][, mixed $REPLACE = null ]) : mixed
Create a key using the provided serialized value, previously obtained using DUMP.. https://redis.io/commands/restore
Parameters
- $key : mixed =
- $ttl : mixed =
- $serializedValue : mixed =
- $REPLACE : mixed = null
role()
public
role() : mixed
Return the role of the instance in the context of replication. https://redis.io/commands/role
rpop()
public
rpop([mixed $key = ]) : mixed
Remove and get the last element in a list. https://redis.io/commands/rpop
Parameters
- $key : mixed =
rpoplpush()
public
rpoplpush([mixed $source = ][, mixed $destination = ]) : mixed
Remove the last element in a list, prepend it to another list and return it. https://redis.io/commands/rpoplpush
Parameters
- $source : mixed =
- $destination : mixed =
rpush()
public
rpush([mixed $key = ][, mixed ...$values = ]) : mixed
Append one or multiple values to a list. https://redis.io/commands/rpush
Parameters
- $key : mixed =
- $values : mixed =
rpushx()
public
rpushx([mixed $key = ][, mixed $value = ]) : mixed
Append a value to a list, only if the list exists. https://redis.io/commands/rpushx
Parameters
- $key : mixed =
- $value : mixed =
sadd()
public
sadd([mixed $key = ][, mixed ...$members = ]) : mixed
Add one or more members to a set. https://redis.io/commands/sadd
Parameters
- $key : mixed =
- $members : mixed =
save()
public
save() : mixed
Synchronously save the dataset to disk. https://redis.io/commands/save
scan()
public
scan([mixed $cursor = ][, mixed $MATCH = null ][, mixed $pattern = null ][, mixed $COUNT = null ][, mixed $count = null ]) : mixed
Incrementally iterate the keys space. https://redis.io/commands/scan
Parameters
- $cursor : mixed =
- $MATCH : mixed = null
- $pattern : mixed = null
- $COUNT : mixed = null
- $count : mixed = null
scard()
public
scard([mixed $key = ]) : mixed
Get the number of members in a set. https://redis.io/commands/scard
Parameters
- $key : mixed =
scriptDebug()
public
scriptDebug([mixed $option = ]) : mixed
Set the debug mode for executed scripts.. https://redis.io/commands/script-debug
Parameters
- $option : mixed =
scriptExists()
public
scriptExists([mixed ...$sha1s = ]) : mixed
Check existence of scripts in the script cache.. https://redis.io/commands/script-exists
Parameters
- $sha1s : mixed =
scriptFlush()
public
scriptFlush() : mixed
Remove all the scripts from the script cache.. https://redis.io/commands/script-flush
scriptKill()
public
scriptKill() : mixed
Kill the script currently in execution.. https://redis.io/commands/script-kill
scriptLoad()
public
scriptLoad([mixed $script = ]) : mixed
Load the specified Lua script into the script cache.. https://redis.io/commands/script-load
Parameters
- $script : mixed =
sdiff()
public
sdiff([mixed ...$keys = ]) : mixed
Subtract multiple sets. https://redis.io/commands/sdiff
Parameters
- $keys : mixed =
sdiffstore()
public
sdiffstore([mixed $destination = ][, mixed ...$keys = ]) : mixed
Subtract multiple sets and store the resulting set in a key. https://redis.io/commands/sdiffstore
Parameters
- $destination : mixed =
- $keys : mixed =
select()
public
select([mixed $index = ]) : mixed
Change the selected database for the current connection. https://redis.io/commands/select
Parameters
- $index : mixed =
set()
public
set([mixed $key = ][, mixed $value = ][, mixed ...$options = ]) : mixed
Set the string value of a key. https://redis.io/commands/set
Parameters
- $key : mixed =
- $value : mixed =
- $options : mixed =
setbit()
public
setbit([mixed $key = ][, mixed $offset = ][, mixed $value = ]) : mixed
Sets or clears the bit at offset in the string value stored at key. https://redis.io/commands/setbit
Parameters
- $key : mixed =
- $offset : mixed =
- $value : mixed =
setex()
public
setex([mixed $key = ][, mixed $seconds = ][, mixed $value = ]) : mixed
Set the value and expiration of a key. https://redis.io/commands/setex
Parameters
- $key : mixed =
- $seconds : mixed =
- $value : mixed =
setnx()
public
setnx([mixed $key = ][, mixed $value = ]) : mixed
Set the value of a key, only if the key does not exist. https://redis.io/commands/setnx
Parameters
- $key : mixed =
- $value : mixed =
setrange()
public
setrange([mixed $key = ][, mixed $offset = ][, mixed $value = ]) : mixed
Overwrite part of a string at key starting at the specified offset. https://redis.io/commands/setrange
Parameters
- $key : mixed =
- $offset : mixed =
- $value : mixed =
shutdown()
public
shutdown([mixed $saveOption = null ]) : mixed
Synchronously save the dataset to disk and then shut down the server. https://redis.io/commands/shutdown
Parameters
- $saveOption : mixed = null
sinter()
public
sinter([mixed ...$keys = ]) : mixed
Intersect multiple sets. https://redis.io/commands/sinter
Parameters
- $keys : mixed =
sinterstore()
public
sinterstore([mixed $destination = ][, mixed ...$keys = ]) : mixed
Intersect multiple sets and store the resulting set in a key. https://redis.io/commands/sinterstore
Parameters
- $destination : mixed =
- $keys : mixed =
sismember()
public
sismember([mixed $key = ][, mixed $member = ]) : mixed
Determine if a given value is a member of a set. https://redis.io/commands/sismember
Parameters
- $key : mixed =
- $member : mixed =
slaveof()
public
slaveof([mixed $host = ][, mixed $port = ]) : mixed
Make the server a slave of another instance, or promote it as master. https://redis.io/commands/slaveof
Parameters
- $host : mixed =
- $port : mixed =
slowlog()
public
slowlog([mixed $subcommand = ][, mixed $argument = null ]) : mixed
Manages the Redis slow queries log. https://redis.io/commands/slowlog
Parameters
- $subcommand : mixed =
- $argument : mixed = null
smembers()
public
smembers([mixed $key = ]) : mixed
Get all the members in a set. https://redis.io/commands/smembers
Parameters
- $key : mixed =
smove()
public
smove([mixed $source = ][, mixed $destination = ][, mixed $member = ]) : mixed
Move a member from one set to another. https://redis.io/commands/smove
Parameters
- $source : mixed =
- $destination : mixed =
- $member : mixed =
sort()
public
sort([mixed $key = ][, mixed ...$options = ]) : mixed
Sort the elements in a list, set or sorted set. https://redis.io/commands/sort
Parameters
- $key : mixed =
- $options : mixed =
spop()
public
spop([mixed $key = ][, mixed $count = null ]) : mixed
Remove and return one or multiple random members from a set. https://redis.io/commands/spop
Parameters
- $key : mixed =
- $count : mixed = null
srandmember()
public
srandmember([mixed $key = ][, mixed $count = null ]) : mixed
Get one or multiple random members from a set. https://redis.io/commands/srandmember
Parameters
- $key : mixed =
- $count : mixed = null
srem()
public
srem([mixed $key = ][, mixed ...$members = ]) : mixed
Remove one or more members from a set. https://redis.io/commands/srem
Parameters
- $key : mixed =
- $members : mixed =
sscan()
public
sscan([mixed $key = ][, mixed $cursor = ][, mixed $MATCH = null ][, mixed $pattern = null ][, mixed $COUNT = null ][, mixed $count = null ]) : mixed
Incrementally iterate Set elements. https://redis.io/commands/sscan
Parameters
- $key : mixed =
- $cursor : mixed =
- $MATCH : mixed = null
- $pattern : mixed = null
- $COUNT : mixed = null
- $count : mixed = null
strlen()
public
strlen([mixed $key = ]) : mixed
Get the length of the value stored in a key. https://redis.io/commands/strlen
Parameters
- $key : mixed =
subscribe()
public
subscribe([mixed ...$channels = ]) : mixed
Listen for messages published to the given channels. https://redis.io/commands/subscribe
Parameters
- $channels : mixed =
sunion()
public
sunion([mixed ...$keys = ]) : mixed
Add multiple sets. https://redis.io/commands/sunion
Parameters
- $keys : mixed =
sunionstore()
public
sunionstore([mixed $destination = ][, mixed ...$keys = ]) : mixed
Add multiple sets and store the resulting set in a key. https://redis.io/commands/sunionstore
Parameters
- $destination : mixed =
- $keys : mixed =
swapdb()
public
swapdb([mixed $index = ]) : mixed
Swaps two Redis databases. https://redis.io/commands/swapdb
Parameters
- $index : mixed =
sync()
public
sync() : mixed
Internal command used for replication. https://redis.io/commands/sync
time()
public
time() : mixed
Return the current server time. https://redis.io/commands/time
touch()
public
touch([mixed ...$keys = ]) : mixed
Alters the last access time of a key(s). Returns the number of existing keys specified.. https://redis.io/commands/touch
Parameters
- $keys : mixed =
trigger()
Triggers an event.
public
trigger(string $name[, Event|null $event = null ]) : mixed
This method represents the happening of an event. It invokes all attached handlers for the event including class-level handlers.
Parameters
- $name : string
-
the event name
- $event : Event|null = null
-
the event instance. If not set, a default [[Event]] object will be created.
ttl()
public
ttl([mixed $key = ]) : mixed
Get the time to live for a key. https://redis.io/commands/ttl
Parameters
- $key : mixed =
type()
public
type([mixed $key = ]) : mixed
Determine the type stored at key. https://redis.io/commands/type
Parameters
- $key : mixed =
unlink()
public
unlink([mixed ...$keys = ]) : mixed
Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.. https://redis.io/commands/unlink
Parameters
- $keys : mixed =
unsubscribe()
public
unsubscribe([mixed ...$channels = ]) : mixed
Stop listening for messages posted to the given channels. https://redis.io/commands/unsubscribe
Parameters
- $channels : mixed =
unwatch()
public
unwatch() : mixed
Forget about all watched keys. https://redis.io/commands/unwatch
wait()
public
wait([mixed $numslaves = ][, mixed $timeout = ]) : mixed
Wait for the synchronous replication of all the write commands sent in the context of the current connection. https://redis.io/commands/wait
Parameters
- $numslaves : mixed =
- $timeout : mixed =
watch()
public
watch([mixed ...$keys = ]) : mixed
Watch the given keys to determine execution of the MULTI/EXEC block. https://redis.io/commands/watch
Parameters
- $keys : mixed =
xack()
public
xack([mixed $stream = ][, mixed $group = ][, mixed ...$ids = ]) : mixed
Removes one or multiple messages from the pending entries list (PEL) of a stream consumer group https://redis.io/commands/xack
Parameters
- $stream : mixed =
- $group : mixed =
- $ids : mixed =
xadd()
public
xadd([mixed $stream = ][, mixed $id = ][, mixed $field = ][, mixed $value = ][, mixed ...$fieldsValues = ]) : mixed
Appends the specified stream entry to the stream at the specified key https://redis.io/commands/xadd
Parameters
- $stream : mixed =
- $id : mixed =
- $field : mixed =
- $value : mixed =
- $fieldsValues : mixed =
xclaim()
public
xclaim([mixed $stream = ][, mixed $group = ][, mixed $consumer = ][, mixed $minIdleTimeMs = ][, mixed $id = ][, mixed ...$options = ]) : mixed
Changes the ownership of a pending message, so that the new owner is the consumer specified as the command argument https://redis.io/commands/xclaim
Parameters
- $stream : mixed =
- $group : mixed =
- $consumer : mixed =
- $minIdleTimeMs : mixed =
- $id : mixed =
- $options : mixed =
xdel()
public
xdel([mixed $stream = ][, mixed ...$ids = ]) : mixed
Removes the specified entries from a stream, and returns the number of entries deleted https://redis.io/commands/xdel
Parameters
- $stream : mixed =
- $ids : mixed =
xgroup()
public
xgroup([mixed $subCommand = ][, mixed $stream = ][, mixed $group = ][, mixed ...$options = ]) : mixed
Manages the consumer groups associated with a stream data structure https://redis.io/commands/xgroup
Parameters
- $subCommand : mixed =
- $stream : mixed =
- $group : mixed =
- $options : mixed =
xinfo()
public
xinfo([mixed $subCommand = ][, mixed $stream = ][, mixed ...$options = ]) : mixed
Retrieves different information about the streams and associated consumer groups https://redis.io/commands/xinfo
Parameters
- $subCommand : mixed =
- $stream : mixed =
- $options : mixed =
xlen()
public
xlen([mixed $stream = ]) : mixed
Returns the number of entries inside a stream https://redis.io/commands/xlen
Parameters
- $stream : mixed =
xpending()
public
xpending([mixed $stream = ][, mixed $group = ][, mixed ...$options = ]) : mixed
Fetching data from a stream via a consumer group, and not acknowledging such data, has the effect of creating pending entries https://redis.io/commands/xpending
Parameters
- $stream : mixed =
- $group : mixed =
- $options : mixed =
xrange()
public
xrange([mixed $stream = ][, mixed $start = ][, mixed $end = ][, mixed ...$options = ]) : mixed
Returns the stream entries matching a given range of IDs https://redis.io/commands/xrange
Parameters
- $stream : mixed =
- $start : mixed =
- $end : mixed =
- $options : mixed =
xread()
public
xread([mixed ...$options = ]) : mixed
Read data from one or multiple streams, only returning entries with an ID greater than the last received ID reported by the caller https://redis.io/commands/xread
Parameters
- $options : mixed =
xreadgroup()
public
xreadgroup([mixed $subCommand = ][, mixed $group = ][, mixed $consumer = ][, mixed ...$options = ]) : mixed
Special version of the XREAD command with support for consumer groups https://redis.io/commands/xreadgroup
Parameters
- $subCommand : mixed =
- $group : mixed =
- $consumer : mixed =
- $options : mixed =
xrevrange()
public
xrevrange([mixed $stream = ][, mixed $end = ][, mixed $start = ][, mixed ...$options = ]) : mixed
Exactly like XRANGE, but with the notable difference of returning the entries in reverse order, and also taking the start-end range in reverse order https://redis.io/commands/xrevrange
Parameters
- $stream : mixed =
- $end : mixed =
- $start : mixed =
- $options : mixed =
xtrim()
public
xtrim([mixed $stream = ][, mixed $strategy = ][, mixed ...$options = ]) : mixed
Trims the stream to a given number of items, evicting older items (items with lower IDs) if needed https://redis.io/commands/xtrim
Parameters
- $stream : mixed =
- $strategy : mixed =
- $options : mixed =
zadd()
public
zadd([mixed $key = ][, mixed ...$options = ]) : mixed
Add one or more members to a sorted set, or update its score if it already exists. https://redis.io/commands/zadd
Parameters
- $key : mixed =
- $options : mixed =
zcard()
public
zcard([mixed $key = ]) : mixed
Get the number of members in a sorted set. https://redis.io/commands/zcard
Parameters
- $key : mixed =
zcount()
public
zcount([mixed $key = ][, mixed $min = ][, mixed $max = ]) : mixed
Count the members in a sorted set with scores within the given values. https://redis.io/commands/zcount
Parameters
- $key : mixed =
- $min : mixed =
- $max : mixed =
zincrby()
public
zincrby([mixed $key = ][, mixed $increment = ][, mixed $member = ]) : mixed
Increment the score of a member in a sorted set. https://redis.io/commands/zincrby
Parameters
- $key : mixed =
- $increment : mixed =
- $member : mixed =
zinterstore()
public
zinterstore([mixed $destination = ][, mixed $numkeys = ][, mixed $key = ][, mixed ...$options = ]) : mixed
Intersect multiple sorted sets and store the resulting sorted set in a new key. https://redis.io/commands/zinterstore
Parameters
- $destination : mixed =
- $numkeys : mixed =
- $key : mixed =
- $options : mixed =
zlexcount()
public
zlexcount([mixed $key = ][, mixed $min = ][, mixed $max = ]) : mixed
Count the number of members in a sorted set between a given lexicographical range. https://redis.io/commands/zlexcount
Parameters
- $key : mixed =
- $min : mixed =
- $max : mixed =
zrange()
public
zrange([mixed $key = ][, mixed $start = ][, mixed $stop = ][, mixed $WITHSCORES = null ]) : mixed
Return a range of members in a sorted set, by index. https://redis.io/commands/zrange
Parameters
- $key : mixed =
- $start : mixed =
- $stop : mixed =
- $WITHSCORES : mixed = null
zrangebylex()
public
zrangebylex([mixed $key = ][, mixed $min = ][, mixed $max = ][, mixed $LIMIT = null ][, mixed $offset = null ][, mixed $count = null ]) : mixed
Return a range of members in a sorted set, by lexicographical range. https://redis.io/commands/zrangebylex
Parameters
- $key : mixed =
- $min : mixed =
- $max : mixed =
- $LIMIT : mixed = null
- $offset : mixed = null
- $count : mixed = null
zrangebyscore()
public
zrangebyscore([mixed $key = ][, mixed $min = ][, mixed $max = ][, mixed ...$options = ]) : mixed
Return a range of members in a sorted set, by score. https://redis.io/commands/zrangebyscore
Parameters
- $key : mixed =
- $min : mixed =
- $max : mixed =
- $options : mixed =
zrank()
public
zrank([mixed $key = ][, mixed $member = ]) : mixed
Determine the index of a member in a sorted set. https://redis.io/commands/zrank
Parameters
- $key : mixed =
- $member : mixed =
zrem()
public
zrem([mixed $key = ][, mixed ...$members = ]) : mixed
Remove one or more members from a sorted set. https://redis.io/commands/zrem
Parameters
- $key : mixed =
- $members : mixed =
zremrangebylex()
public
zremrangebylex([mixed $key = ][, mixed $min = ][, mixed $max = ]) : mixed
Remove all members in a sorted set between the given lexicographical range. https://redis.io/commands/zremrangebylex
Parameters
- $key : mixed =
- $min : mixed =
- $max : mixed =
zremrangebyrank()
public
zremrangebyrank([mixed $key = ][, mixed $start = ][, mixed $stop = ]) : mixed
Remove all members in a sorted set within the given indexes. https://redis.io/commands/zremrangebyrank
Parameters
- $key : mixed =
- $start : mixed =
- $stop : mixed =
zremrangebyscore()
public
zremrangebyscore([mixed $key = ][, mixed $min = ][, mixed $max = ]) : mixed
Remove all members in a sorted set within the given scores. https://redis.io/commands/zremrangebyscore
Parameters
- $key : mixed =
- $min : mixed =
- $max : mixed =
zrevrange()
public
zrevrange([mixed $key = ][, mixed $start = ][, mixed $stop = ][, mixed $WITHSCORES = null ]) : mixed
Return a range of members in a sorted set, by index, with scores ordered from high to low. https://redis.io/commands/zrevrange
Parameters
- $key : mixed =
- $start : mixed =
- $stop : mixed =
- $WITHSCORES : mixed = null
zrevrangebylex()
public
zrevrangebylex([mixed $key = ][, mixed $max = ][, mixed $min = ][, mixed $LIMIT = null ][, mixed $offset = null ][, mixed $count = null ]) : mixed
Return a range of members in a sorted set, by lexicographical range, ordered from higher to lower strings.. https://redis.io/commands/zrevrangebylex
Parameters
- $key : mixed =
- $max : mixed =
- $min : mixed =
- $LIMIT : mixed = null
- $offset : mixed = null
- $count : mixed = null
zrevrangebyscore()
public
zrevrangebyscore([mixed $key = ][, mixed $max = ][, mixed $min = ][, mixed $WITHSCORES = null ][, mixed $LIMIT = null ][, mixed $offset = null ][, mixed $count = null ]) : mixed
Return a range of members in a sorted set, by score, with scores ordered from high to low. https://redis.io/commands/zrevrangebyscore
Parameters
- $key : mixed =
- $max : mixed =
- $min : mixed =
- $WITHSCORES : mixed = null
- $LIMIT : mixed = null
- $offset : mixed = null
- $count : mixed = null
zrevrank()
public
zrevrank([mixed $key = ][, mixed $member = ]) : mixed
Determine the index of a member in a sorted set, with scores ordered from high to low. https://redis.io/commands/zrevrank
Parameters
- $key : mixed =
- $member : mixed =
zscan()
public
zscan([mixed $key = ][, mixed $cursor = ][, mixed $MATCH = null ][, mixed $pattern = null ][, mixed $COUNT = null ][, mixed $count = null ]) : mixed
Incrementally iterate sorted sets elements and associated scores. https://redis.io/commands/zscan
Parameters
- $key : mixed =
- $cursor : mixed =
- $MATCH : mixed = null
- $pattern : mixed = null
- $COUNT : mixed = null
- $count : mixed = null
zscore()
public
zscore([mixed $key = ][, mixed $member = ]) : mixed
Get the score associated with the given member in a sorted set. https://redis.io/commands/zscore
Parameters
- $key : mixed =
- $member : mixed =
zunionstore()
public
zunionstore([mixed $destination = ][, mixed $numkeys = ][, mixed $key = ][, mixed ...$options = ]) : mixed
Add multiple sorted sets and store the resulting sorted set in a new key. https://redis.io/commands/zunionstore
Parameters
- $destination : mixed =
- $numkeys : mixed =
- $key : mixed =
- $options : mixed =
initConnection()
Initializes the DB connection.
protected
initConnection() : mixed
This method is invoked right after the DB connection is established. The default implementation triggers an [[EVENT_AFTER_OPEN]] event.
sendRawCommand()
Sends RAW command string to the server.
protected
sendRawCommand(string $command, array<string|int, mixed> $params) : array<string|int, mixed>|bool|null|string
Parameters
- $command : string
-
command string
- $params : array<string|int, mixed>
-
list of parameters for the command
Tags
Return values
array<string|int, mixed>|bool|null|string —Dependent on the executed command this method will return different data types:
-
true
for commands that return "status reply" with the message'OK'
or'PONG'
. -
string
for commands that return "status reply" that does not have the messageOK
(since version 2.0.1). -
string
for commands that return "integer reply" as the value is in the range of a signed 64 bit integer. -
string
ornull
for commands that return "bulk reply". -
array
for commands that return "Multi-bulk replies".
See redis protocol description for details on the mentioned reply types.
attachBehaviorInternal()
Attaches a behavior to this component.
private
attachBehaviorInternal(string|int $name, string|array<string|int, mixed>|Behavior $behavior) : Behavior
Parameters
- $name : string|int
-
the name of the behavior. If this is an integer, it means the behavior is an anonymous one. Otherwise, the behavior is a named one and any existing behavior with the same name will be detached first.
- $behavior : string|array<string|int, mixed>|Behavior
-
the behavior to be attached
Return values
Behavior —the attached behavior.
isRedirect()
private
isRedirect(string $line) : bool
Parameters
- $line : string
Return values
boolparseResponse()
private
parseResponse(array<string|int, mixed> $params[, string|null $command = null ]) : mixed
Parameters
- $params : array<string|int, mixed>
- $command : string|null = null
Tags
redirect()
private
redirect(string $redirect, string $command, array<string|int, mixed> $params) : mixed
Parameters
- $redirect : string
- $command : string
- $params : array<string|int, mixed>