MediaWiki REL1_32
RedisConnRef Class Reference

Helper class to handle automatically marking connectons as reusable (via RAII pattern) More...

Inheritance diagram for RedisConnRef:
Collaboration diagram for 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 explicity 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 explicity due to needing the iterator passed by reference.
 
 setLogger (LoggerInterface $logger)
 
 sScan ( $key, &$iterator, $pattern=null, $count=null)
 Set Scan Handle this explicity due to needing the iterator passed by reference.
 
 zScan ( $key, &$iterator, $pattern=null, $count=null)
 Sorted Set Scan Handle this explicity due to needing the iterator passed by reference.
 

Protected Attributes

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

Private Member Functions

 checkAuthentication ()
 Handle authentication errors and automatically reauthenticate.
 
 postCallCleanup ()
 Post Redis call cleanup.
 
 tryCall ( $method, $arguments)
 Do the method call in the common try catch handler.
 

Detailed Description

Helper class to handle automatically marking connectons as reusable (via RAII pattern)

This class simply wraps the Redis class and can be used the same way

Since
1.21

Definition at line 31 of file RedisConnRef.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 72 of file RedisConnRef.php.

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

◆ __destruct()

RedisConnRef::__destruct ( )

Definition at line 303 of file RedisConnRef.php.

Member Function Documentation

◆ __call()

RedisConnRef::__call ( $name,
$arguments )

Magic __call handler for most Redis functions.

Parameters
string$name
array$arguments
Returns
mixed $res
Exceptions
RedisException

Definition at line 109 of file RedisConnRef.php.

References tryCall().

◆ checkAuthentication()

RedisConnRef::checkAuthentication ( )
private

Handle authentication errors and automatically reauthenticate.

Returns
constant self::AUTH_NO_ERROR, self::AUTH_ERROR_TEMPORARY, or self::AUTH_ERROR_PERMANENT

Definition at line 215 of file RedisConnRef.php.

Referenced by tryCall().

◆ clearLastError()

RedisConnRef::clearLastError ( )

Definition at line 97 of file RedisConnRef.php.

◆ getLastError()

RedisConnRef::getLastError ( )

Definition at line 93 of file RedisConnRef.php.

References $lastError.

◆ getServer()

RedisConnRef::getServer ( )
Returns
string
Since
1.23

Definition at line 89 of file RedisConnRef.php.

References $server.

◆ hScan()

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

Hash Scan Handle this explicity 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 $res

Definition at line 191 of file RedisConnRef.php.

References tryCall().

◆ isConnIdentical()

RedisConnRef::isConnIdentical ( Redis $conn)
Parameters
Redis$conn
Returns
bool

Definition at line 299 of file RedisConnRef.php.

References $conn.

◆ luaEval()

RedisConnRef::luaEval ( $script,
array $params,
$numKeys )
Parameters
string$script
array$params
int$numKeys
Returns
mixed
Exceptions
RedisException

Definition at line 249 of file RedisConnRef.php.

References $conn, $lastError, $params, $res, and $server.

Referenced by PoolCounterRedis\initAndPopPoolSlotList(), JobQueueRedis\popAndAcquireBlob(), JobQueueRedis\pushBlobs(), PoolCounterRedis\registerAcquisitionTime(), and PoolCounterRedis\release().

◆ postCallCleanup()

RedisConnRef::postCallCleanup ( )
private

Post Redis call cleanup.

Returns
void

Definition at line 235 of file RedisConnRef.php.

References $lastError.

Referenced by tryCall().

◆ scan()

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

Key Scan Handle this explicity 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 $res

Definition at line 161 of file RedisConnRef.php.

References tryCall().

◆ setLogger()

RedisConnRef::setLogger ( LoggerInterface $logger)

Definition at line 81 of file RedisConnRef.php.

References $logger.

◆ sScan()

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

Set Scan Handle this explicity 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 $res

Definition at line 176 of file RedisConnRef.php.

References tryCall().

◆ tryCall()

RedisConnRef::tryCall ( $method,
$arguments )
private

Do the method call in the common try catch handler.

Parameters
string$method
array$arguments
Returns
mixed $res
Exceptions
RedisException

Definition at line 133 of file RedisConnRef.php.

References $res, checkAuthentication(), and postCallCleanup().

Referenced by __call(), hScan(), scan(), sScan(), and zScan().

◆ zScan()

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

Sorted Set Scan Handle this explicity 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 $res

Definition at line 206 of file RedisConnRef.php.

References tryCall().

Member Data Documentation

◆ $conn

Redis RedisConnRef::$conn
protected

Definition at line 35 of file RedisConnRef.php.

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

◆ $lastError

RedisConnRef::$lastError
protected

Definition at line 38 of file RedisConnRef.php.

Referenced by getLastError(), luaEval(), and postCallCleanup().

◆ $logger

LoggerInterface RedisConnRef::$logger
protected

Definition at line 43 of file RedisConnRef.php.

Referenced by __construct(), and setLogger().

◆ $pool

RedisConnectionPool RedisConnRef::$pool
protected

Definition at line 33 of file RedisConnRef.php.

Referenced by __construct().

◆ $server

RedisConnRef::$server
protected

Definition at line 37 of file RedisConnRef.php.

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


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