MediaWiki master
Wikimedia\ObjectCache\RedisConnRef Class Reference

Wrapper class for Redis connections that automatically reuses connections (via RAII pattern). More...

Inherits LoggerAwareInterface.

Collaboration diagram for Wikimedia\ObjectCache\RedisConnRef:

Public Member Functions

 __call ( $name, $arguments)
 Magic __call handler for most Redis functions.
 __construct (RedisConnectionPool $pool, $server, Redis $conn, LoggerInterface $logger)
 __destruct ()
 clearLastError ()
 getLastError ()
 getServer ()
 hScan ( $key, &$iterator, $pattern=null, $count=null)
 Hash Scan Handle this explicitly due to needing the iterator passed by reference.
 isConnIdentical (Redis $conn)
 luaEval ( $script, array $params, $numKeys)
 scan (&$iterator, $pattern=null, $count=null)
 Key Scan Handle this explicitly due to needing the iterator passed by reference.
 setLogger (LoggerInterface $logger)
 sScan ( $key, &$iterator, $pattern=null, $count=null)
 Set Scan Handle this explicitly due to needing the iterator passed by reference.
 zScan ( $key, &$iterator, $pattern=null, $count=null)
 Sorted Set Scan Handle this explicitly due to needing the iterator passed by reference.

Protected Attributes

Redis $conn
string null $lastError
LoggerInterface $logger
RedisConnectionPool $pool
string $server

Detailed Description

Wrapper class for Redis connections that automatically reuses connections (via RAII pattern).

This class proxies a Redis class instance from the php-redis PECL extension. All its methods can be called the same way.

See also
https://github.com/phpredis/phpredis#table-of-contents
Since
1.21

Definition at line 25 of file RedisConnRef.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\ObjectCache\RedisConnRef::__construct ( RedisConnectionPool $pool,
$server,
Redis $conn,
LoggerInterface $logger )
Parameters
RedisConnectionPool$pool
string$server
Redis$conn
LoggerInterface$logger

Definition at line 61 of file RedisConnRef.php.

References $conn, $logger, $pool, and $server.

◆ __destruct()

Wikimedia\ObjectCache\RedisConnRef::__destruct ( )

Definition at line 297 of file RedisConnRef.php.

Member Function Documentation

◆ __call()

Wikimedia\ObjectCache\RedisConnRef::__call ( $name,
$arguments )

Magic __call handler for most Redis functions.

Parameters
string$name
array$arguments
Returns
mixed
Exceptions
RedisException

Definition at line 101 of file RedisConnRef.php.

◆ clearLastError()

Wikimedia\ObjectCache\RedisConnRef::clearLastError ( )

Definition at line 89 of file RedisConnRef.php.

◆ getLastError()

Wikimedia\ObjectCache\RedisConnRef::getLastError ( )
Returns
string|null

Definition at line 85 of file RedisConnRef.php.

◆ getServer()

Wikimedia\ObjectCache\RedisConnRef::getServer ( )
Returns
string
Since
1.23

Definition at line 78 of file RedisConnRef.php.

Referenced by Wikimedia\ObjectCache\RedisConnectionPool\handleError().

◆ hScan()

Wikimedia\ObjectCache\RedisConnRef::hScan ( $key,
& $iterator,
$pattern = null,
$count = null )

Hash Scan Handle this explicitly due to needing the iterator passed by reference.

See: https://github.com/phpredis/phpredis#hScan

Parameters
string$key
int&$iterator
string | null$pattern
int | null$count
Returns
array

Definition at line 182 of file RedisConnRef.php.

◆ isConnIdentical()

Wikimedia\ObjectCache\RedisConnRef::isConnIdentical ( Redis $conn)
Parameters
Redis$conn
Returns
bool

Definition at line 293 of file RedisConnRef.php.

References $conn.

Referenced by Wikimedia\ObjectCache\RedisConnectionPool\handleError().

◆ luaEval()

Wikimedia\ObjectCache\RedisConnRef::luaEval ( $script,
array $params,
$numKeys )

◆ scan()

Wikimedia\ObjectCache\RedisConnRef::scan ( & $iterator,
$pattern = null,
$count = null )

Key Scan Handle this explicitly due to needing the iterator passed by reference.

See: https://github.com/phpredis/phpredis#scan

Parameters
int&$iterator
string | null$pattern
int | null$count
Returns
array

Definition at line 152 of file RedisConnRef.php.

◆ setLogger()

Wikimedia\ObjectCache\RedisConnRef::setLogger ( LoggerInterface $logger)

Definition at line 70 of file RedisConnRef.php.

References $logger.

◆ sScan()

Wikimedia\ObjectCache\RedisConnRef::sScan ( $key,
& $iterator,
$pattern = null,
$count = null )

Set Scan Handle this explicitly due to needing the iterator passed by reference.

See: https://github.com/phpredis/phpredis#sScan

Parameters
string$key
int&$iterator
string | null$pattern
int | null$count
Returns
array

Definition at line 167 of file RedisConnRef.php.

◆ zScan()

Wikimedia\ObjectCache\RedisConnRef::zScan ( $key,
& $iterator,
$pattern = null,
$count = null )

Sorted Set Scan Handle this explicitly due to needing the iterator passed by reference.

See: https://github.com/phpredis/phpredis#hScan

Parameters
string$key
int&$iterator
string | null$pattern
int | null$count
Returns
array

Definition at line 197 of file RedisConnRef.php.

Member Data Documentation

◆ $conn

Redis Wikimedia\ObjectCache\RedisConnRef::$conn
protected

Definition at line 29 of file RedisConnRef.php.

Referenced by __construct(), isConnIdentical(), and luaEval().

◆ $lastError

string null Wikimedia\ObjectCache\RedisConnRef::$lastError
protected

Definition at line 33 of file RedisConnRef.php.

Referenced by luaEval().

◆ $logger

LoggerInterface Wikimedia\ObjectCache\RedisConnRef::$logger
protected

Definition at line 38 of file RedisConnRef.php.

Referenced by __construct(), and setLogger().

◆ $pool

RedisConnectionPool Wikimedia\ObjectCache\RedisConnRef::$pool
protected

Definition at line 27 of file RedisConnRef.php.

Referenced by __construct().

◆ $server

string Wikimedia\ObjectCache\RedisConnRef::$server
protected

Definition at line 31 of file RedisConnRef.php.

Referenced by __construct(), and luaEval().


The documentation for this class was generated from the following file: