PHP Class Credis_Cluster

Deprecation:
Mostrar archivo Open project: colinmollenhour/credis Class Usage Examples

Protected Properties

Property Type Description
$aliases array Aliases of Credis_Client objects attached to Redis servers, used to route commands to specific servers
$clients Credis_Client[] Collection of Credis_Client objects attached to Redis servers
$dont_hash array The commands that are not subject to hashing
$masterClient Credis_Client If a server is set as master, all write commands go to that one
$nodes array Individual nodes of pointers to Redis servers on the hash ring
$ring array Hash ring of Redis server nodes
$selectedDb integer Currently working cluster-wide database number.

Public Methods

Method Description
__call ( string $name, array $args ) : mixed Execute a Redis command on the cluster with automatic consistent hashing and read/write splitting
__construct ( array $servers, integer $replicas = 128, boolean $standAlone = false ) Creates an interface to a cluster of Redis servers Each server should be in the format: array( 'host' => hostname, 'port' => port, 'db' => db, 'password' => password, 'timeout' => timeout, 'alias' => alias, 'persistent' => persistence_identifier, 'master' => master 'write_only'=> true/false )
all ( ) : array Execute a command on all clients
byHash ( string $key ) : Credis_Client Get the client that the key would hash to.
client ( string | integer $alias ) : Credis_Client Get a client by index or alias.
clients ( ) : array | Credis_Client[] Get an array of all clients
hash ( string $key ) : integer Get client index for a key by searching ring with binary search
isReadOnlyCommand ( $command )
select ( integer $index ) : void
setMasterClient ( Credis_Client $masterClient, boolean $writeOnly = false ) : Credis_Cluster

Method Details

__call() public method

Execute a Redis command on the cluster with automatic consistent hashing and read/write splitting
public __call ( string $name, array $args ) : mixed
$name string
$args array
return mixed

__construct() public method

Creates an interface to a cluster of Redis servers Each server should be in the format: array( 'host' => hostname, 'port' => port, 'db' => db, 'password' => password, 'timeout' => timeout, 'alias' => alias, 'persistent' => persistence_identifier, 'master' => master 'write_only'=> true/false )
public __construct ( array $servers, integer $replicas = 128, boolean $standAlone = false )
$servers array The Redis servers in the cluster.
$replicas integer
$standAlone boolean

all() public method

Execute a command on all clients
public all ( ) : array
return array

byHash() public method

Get the client that the key would hash to.
public byHash ( string $key ) : Credis_Client
$key string
return Credis_Client

client() public method

Get a client by index or alias.
public client ( string | integer $alias ) : Credis_Client
$alias string | integer
return Credis_Client

clients() public method

Get an array of all clients
public clients ( ) : array | Credis_Client[]
return array | Credis_Client[]

hash() public method

Get client index for a key by searching ring with binary search
public hash ( string $key ) : integer
$key string The key to hash
return integer The index of the client object associated with the hash of the key

isReadOnlyCommand() public method

public isReadOnlyCommand ( $command )

select() public method

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

setMasterClient() public method

public setMasterClient ( Credis_Client $masterClient, boolean $writeOnly = false ) : Credis_Cluster
$masterClient Credis_Client
$writeOnly boolean
return Credis_Cluster

Property Details

$aliases protected_oe property

Aliases of Credis_Client objects attached to Redis servers, used to route commands to specific servers
See also: Credis_Cluster::to
protected array $aliases
return array

$clients protected_oe property

Collection of Credis_Client objects attached to Redis servers
protected Credis_Client[] $clients
return Credis_Client[]

$dont_hash protected_oe property

The commands that are not subject to hashing
protected array $dont_hash
return array

$masterClient protected_oe property

If a server is set as master, all write commands go to that one
protected Credis_Client $masterClient
return Credis_Client

$nodes protected_oe property

Individual nodes of pointers to Redis servers on the hash ring
protected array $nodes
return array

$ring protected_oe property

Hash ring of Redis server nodes
protected array $ring
return array

$selectedDb protected_oe property

Currently working cluster-wide database number.
protected int $selectedDb
return integer