PHP Class Credis_Client

Server/Connection:
Mostrar archivo Open project: colinmollenhour/credis Class Usage Examples

Protected Properties

Property Type Description
$authPassword string
$closeOnDestruct boolean
$commandNames array
$commands string
$connectFailures integer
$connected boolean
$host string Host of the Redis server
$isMulti boolean
$isWatching boolean
$maxConnectRetries integer
$persistent string Unique identifier for persistent connections
$port integer Port on which the Redis server is running
$readTimeout float Timeout for reading response from Redis server
$redis resource | Redis Socket connection to the Redis server or Redis library instance
$redisMulti
$renamedCommands array
$requests integer
$selectedDb integer
$standalone boolean
$subscribed boolean
$timeout float Timeout for connecting to Redis server
$usePipeline boolean
$wrapperMethods array Aliases for backwards compatibility with phpredis

Public Methods

Method Description
__call ( $name, $args )
__construct ( string $host = '127.0.0.1', integer $port = 6379, float $timeout = null, string $persistent = '', integer $db, string $password = null ) Creates a Redisent connection to the Redis server on host {@link $host} and port {@link $port}.
__destruct ( )
auth ( string $password ) : boolean
close ( ) : boolean
connect ( ) : Credis_Client
forceStandalone ( ) : Credis_Client
getHost ( ) : string Return the host of the Redis instance
getPersistence ( ) : string
getPort ( ) : integer Return the port of the Redis instance
getRenamedCommand ( $command )
getSelectedDb ( ) : integer Return the selected database
hscan ( integer &$Iterator, string $field, string $pattern = null, integer $count = null ) : boolean | Array
isConnected ( ) : boolean
isSubscribed ( ) : boolean
pSubscribe ( string | array $patterns, $callback )
pUnsubscribe ( ) : array
renameCommand ( string | callable | array $command, string | null $alias = NULL ) Enabled command renaming and provide mapping method. Supported methods are:
scan ( integer &$Iterator, string $pattern = null, $count = null ) : boolean | Array
select ( integer $index ) : boolean
setCloseOnDestruct ( boolean $flag ) : Credis_Client
setMaxConnectRetries ( integer $retries ) : Credis_Client
setReadTimeout ( integer $timeout ) : Credis_Client Set the read timeout for the connection. Use 0 to disable timeouts entirely (or use a very long timeout if not supported).
sscan ( integer &$Iterator, string $field, string $pattern = null, $count = null ) : boolean | Array
subscribe ( string | array $channels, $callback )
unsubscribe ( ) : array
zscan ( integer &$Iterator, string $field, string $pattern = null, $count = null ) : boolean | Array

Protected Methods

Method Description
convertHost ( )
read_reply ( $name = '' )
write_command ( $command )

Private Methods

Method Description
_flattenArguments ( array $arguments, &$out = [] ) : array Flatten arguments
_map ( $arg )
_prepare_command ( array $args ) : string Build the Redis unified protocol command

Method Details

__call() public method

public __call ( $name, $args )

__construct() public method

$host may also be a path to a unix socket or a string in the form of tcp://[hostname]:[port] or unix://[path]
public __construct ( string $host = '127.0.0.1', integer $port = 6379, float $timeout = null, string $persistent = '', integer $db, string $password = null )
$host string The hostname of the Redis server
$port integer The port number of the Redis server
$timeout float Timeout period in seconds
$persistent string Flag to establish persistent connection
$db integer The selected datbase of the Redis server
$password string The authentication password of the Redis server

__destruct() public method

public __destruct ( )

auth() public method

public auth ( string $password ) : boolean
$password string
return boolean

close() public method

public close ( ) : boolean
return boolean

connect() public method

public connect ( ) : Credis_Client
return Credis_Client

convertHost() protected method

protected convertHost ( )

forceStandalone() public method

public forceStandalone ( ) : Credis_Client
return Credis_Client

getHost() public method

Return the host of the Redis instance
public getHost ( ) : string
return string

getPersistence() public method

public getPersistence ( ) : string
return string

getPort() public method

Return the port of the Redis instance
public getPort ( ) : integer
return integer

getRenamedCommand() public method

public getRenamedCommand ( $command )
$command

getSelectedDb() public method

Return the selected database
public getSelectedDb ( ) : integer
return integer

hscan() public method

public hscan ( integer &$Iterator, string $field, string $pattern = null, integer $count = null ) : boolean | Array
$Iterator integer
$field string
$pattern string
$count integer
return boolean | Array | Array

isConnected() public method

public isConnected ( ) : boolean
return boolean

isSubscribed() public method

public isSubscribed ( ) : boolean
return boolean

pSubscribe() public method

public pSubscribe ( string | array $patterns, $callback )
$patterns string | array
$callback

pUnsubscribe() public method

public pUnsubscribe ( ) : array
return array

read_reply() protected method

protected read_reply ( $name = '' )

renameCommand() public method

1. renameCommand('foo') // Salted md5 hash for all commands -> md5('foo'.$command) 2. renameCommand(function($command){ return 'my'.$command; }); // Callable 3. renameCommand('get', 'foo') // Single command -> alias 4. renameCommand(['get' => 'foo', 'set' => 'bar']) // Full map of [command -> alias]
public renameCommand ( string | callable | array $command, string | null $alias = NULL )
$command string | callable | array
$alias string | null

scan() public method

public scan ( integer &$Iterator, string $pattern = null, $count = null ) : boolean | Array
$Iterator integer
$pattern string
return boolean | Array | Array

select() public method

public select ( integer $index ) : boolean
$index integer
return boolean

setCloseOnDestruct() public method

public setCloseOnDestruct ( boolean $flag ) : Credis_Client
$flag boolean
return Credis_Client

setMaxConnectRetries() public method

public setMaxConnectRetries ( integer $retries ) : Credis_Client
$retries integer
return Credis_Client

setReadTimeout() public method

Set the read timeout for the connection. Use 0 to disable timeouts entirely (or use a very long timeout if not supported).
public setReadTimeout ( integer $timeout ) : Credis_Client
$timeout integer 0 (or -1) for no timeout, otherwise number of seconds
return Credis_Client

sscan() public method

public sscan ( integer &$Iterator, string $field, string $pattern = null, $count = null ) : boolean | Array
$Iterator integer
$field string
$pattern string
return boolean | Array | Array

subscribe() public method

public subscribe ( string | array $channels, $callback )
$channels string | array
$callback

unsubscribe() public method

public unsubscribe ( ) : array
return array

write_command() protected method

protected write_command ( $command )

zscan() public method

public zscan ( integer &$Iterator, string $field, string $pattern = null, $count = null ) : boolean | Array
$Iterator integer
$field string
$pattern string
return boolean | Array | Array

Property Details

$authPassword protected_oe property

protected string $authPassword
return string

$closeOnDestruct protected_oe property

protected bool $closeOnDestruct
return boolean

$commandNames protected_oe property

protected array $commandNames
return array

$commands protected_oe property

protected string $commands
return string

$connectFailures protected_oe property

protected int $connectFailures
return integer

$connected protected_oe property

protected bool $connected
return boolean

$host protected_oe property

Host of the Redis server
protected string $host
return string

$isMulti protected_oe property

protected bool $isMulti
return boolean

$isWatching protected_oe property

protected bool $isWatching
return boolean

$maxConnectRetries protected_oe property

protected int $maxConnectRetries
return integer

$persistent protected_oe property

Unique identifier for persistent connections
protected string $persistent
return string

$port protected_oe property

Port on which the Redis server is running
protected int $port
return integer

$readTimeout protected_oe property

Timeout for reading response from Redis server
protected float $readTimeout
return float

$redis protected_oe property

Socket connection to the Redis server or Redis library instance
protected resource|Redis $redis
return resource | Redis

$redisMulti protected_oe property

protected $redisMulti

$renamedCommands protected_oe property

protected array $renamedCommands
return array

$requests protected_oe property

protected int $requests
return integer

$selectedDb protected_oe property

protected int $selectedDb
return integer

$standalone protected_oe property

protected bool $standalone
return boolean

$subscribed protected_oe property

protected bool $subscribed
return boolean

$timeout protected_oe property

Timeout for connecting to Redis server
protected float $timeout
return float

$usePipeline protected_oe property

protected bool $usePipeline
return boolean

$wrapperMethods protected_oe property

Aliases for backwards compatibility with phpredis
protected array $wrapperMethods
return array