[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/clientpool/ -> RedisConnectionPool.php (summary)

Redis client connection pooling manager. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Author: Aaron Schulz
File Size: 497 lines (16 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

RedisConnectionPool:: (11 methods):
  __construct()
  applyDefaultConfig()
  singleton()
  getConnection()
  freeConnection()
  closeExcessIdleConections()
  handleException()
  handleError()
  reauthenticateConnection()
  resetTimeout()
  __destruct()

RedisConnRef:: (8 methods):
  __construct()
  getServer()
  getLastError()
  clearLastError()
  __call()
  luaEval()
  isConnIdentical()
  __destruct()


Class: RedisConnectionPool  - X-Ref

Helper class to manage Redis connections.

This can be used to get handle wrappers that free the handle when the wrapper
leaves scope. The maximum number of free handles (connections) is configurable.
This provides an easy way to cache connection handles that may also have state,
such as a handle does between multi() and exec(), and without hoarding connections.
The wrappers use PHP magic methods so that calling functions on them calls the
function of the actual Redis object handle.

__construct( array $options )   X-Ref

param: array $options

applyDefaultConfig( array $options )   X-Ref

param: array $options
return: array

singleton( array $options )   X-Ref

param: array $options
return: RedisConnectionPool

getConnection( $server )   X-Ref
Get a connection to a redis server. Based on code in RedisBagOStuff.php.

param: string $server A hostname/port combination or the absolute path of a UNIX socket.
return: RedisConnRef|bool Returns false on failure

freeConnection( $server, Redis $conn )   X-Ref
Mark a connection to a server as free to return to the pool

param: string $server
param: Redis $conn
return: bool

closeExcessIdleConections()   X-Ref
Close any extra idle connections if there are more than the limit


handleException( $server, RedisConnRef $cref, RedisException $e )   X-Ref
The redis extension throws an exception in response to various read, write
and protocol errors. Sometimes it also closes the connection, sometimes
not. The safest response for us is to explicitly destroy the connection
object and let it be reopened during the next request.

param: string $server
param: RedisConnRef $cref
param: RedisException $e

handleError( RedisConnRef $cref, RedisException $e )   X-Ref
The redis extension throws an exception in response to various read, write
and protocol errors. Sometimes it also closes the connection, sometimes
not. The safest response for us is to explicitly destroy the connection
object and let it be reopened during the next request.

param: RedisConnRef $cref
param: RedisException $e

reauthenticateConnection( $server, Redis $conn )   X-Ref
Re-send an AUTH request to the redis server (useful after disconnects).

This works around an upstream bug in phpredis. phpredis hides disconnects by transparently
reconnecting, but it neglects to re-authenticate the new connection. To the user of the
phpredis client API this manifests as a seemingly random tendency of connections to lose
their authentication status.

This method is for internal use only.

param: string $server
param: Redis $conn
return: bool Success

resetTimeout( Redis $conn, $timeout = null )   X-Ref
Adjust or reset the connection handle read timeout value

param: Redis $conn
param: int $timeout Optional

__destruct()   X-Ref
Make sure connections are closed for sanity


Class: RedisConnRef  - X-Ref

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

__construct( RedisConnectionPool $pool, $server, Redis $conn )   X-Ref

param: RedisConnectionPool $pool
param: string $server
param: Redis $conn

getServer()   X-Ref

return: string

getLastError()   X-Ref
No description

clearLastError()   X-Ref
No description

__call( $name, $arguments )   X-Ref
No description

luaEval( $script, array $params, $numKeys )   X-Ref

param: string $script
param: array $params
param: int $numKeys
return: mixed

isConnIdentical( Redis $conn )   X-Ref

param: Redis $conn
return: bool

__destruct()   X-Ref
No description



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1