Constants

MAX_TOKEN

MAX_TOKEN

TOKEN最大值

ASYN_NAME

ASYN_NAME

连接池类型名称

Properties

$config

$config : \Noodlehaus\Config

Type

\Noodlehaus\Config — 配置对象

$connect

$connect : array

Type

array — 连接配置信息

$redisClient

$redisClient : \Redis

Type

\Redis — 同步Redis客户端

$keyPrefix

$keyPrefix : string

Type

string — Redis Key前缀

$hashKey

$hashKey : boolean

Type

boolean — 是否需要hash key

$phpSerialize

$phpSerialize : boolean

Type

boolean — 是否启用PHP序列化

$redisSerialize

$redisSerialize : boolean

Type

boolean — 是否启用Redis序列化

$commands

$commands : \SplQueue

Type

\SplQueue — 待执行命令队列

$pool

$pool : \SplQueue

Type

\SplQueue — 连接池

$callBacks

$callBacks : array

Type

array — 回调函数

$workerId

$workerId : integer

Type

integer — worker进程ID

$server

$server : \swoole_server

Type

\swoole_server — swoole_server实例

$swooleServer

$swooleServer : \PG\MSF\MSFServer

Type

\PG\MSF\MSFServer — server运行实例

$token

$token : integer

Type

integer — 回调Token

$waitConnectNum

$waitConnectNum : integer

Type

integer — 待连接数量

$redisMaxCount

$redisMaxCount : integer

Type

integer — 连接峰值

$active

$active : string

Type

string — 连接池标识

Methods

__construct()

__construct(\Noodlehaus\Config  $config, string  $active) 

RedisAsynPool constructor.

Parameters

\Noodlehaus\Config $config

配置对象

string $active

连接池名称

Throws

\Exception

addTokenCallback()

addTokenCallback(callable  $callback) : integer

注册回调

Parameters

callable $callback

回调函数

Returns

integer

distribute()

distribute(array  $data) : $this

分发消息

Parameters

array $data

待分发数据

Returns

$this

serverInit()

serverInit(\PG\MSF\MSFServer  $swooleServer, \PG\MSF\Pools\AsynPoolManager  $asynManager) : $this

初始化

Parameters

\PG\MSF\MSFServer $swooleServer

Server实例

\PG\MSF\Pools\AsynPoolManager $asynManager

异步连接池管理器

Returns

$this

workerInit()

workerInit(integer  $workerId) : $this

初始化workerId

Parameters

integer $workerId

worker进程ID

Returns

$this

pushToPool()

pushToPool(mixed  $client) : $this

归还连接

Parameters

mixed $client

连接对象

Returns

$this

getSync()

getSync() : \Redis

获取同步

Throws

\Exception

Returns

\Redis

__call()

__call(string  $name, array  $arguments) 

__call魔术方法,映射redis方法

Parameters

string $name

Redis指令

array $arguments

Redis指令参数

go()

go(\PG\MSF\Helpers\Context  $context, string  $name, array  $arg) : mixed|\PG\MSF\Coroutine\Redis

协程模式

Parameters

\PG\MSF\Helpers\Context $context

请求上下文对象

string $name

Redis指令

array $arg

Redis指令参数

Throws

\Exception

Returns

mixed|\PG\MSF\Coroutine\Redis

getCoroutine()

getCoroutine() : \Redis|\PG\MSF\Pools\coroutineRedisProxy

便捷协程模式

Returns

\Redis|\PG\MSF\Pools\coroutineRedisProxy

execute()

execute(array  $data) 

执行Redis命令

Parameters

array $data

Redis命令相关信息

prepareOne()

prepareOne() 

创建一个Redis连接

reconnect()

reconnect(\swoole_redis|null  $client = null) 

重连或者连接

Parameters

\swoole_redis|null $client

连接对象

onClose()

onClose(\swoole_redis  $client) 

断开链接

Parameters

\swoole_redis $client

连接对象

getAsynName()

getAsynName() : string

返回唯一的连接池名称

Returns

string