# \PG\MSF\PoolsRedisAsynPool

Class RedisAsynPool

## Summary

Methods
Properties
Constants
__construct()
addTokenCallback()
distribute()
serverInit()
workerInit()
pushToPool()
getSync()
__call()
go()
getCoroutine()
execute()
prepareOne()
reconnect()
onClose()
getAsynName()
$config
$connect
$redisClient
$keyPrefix
$hashKey
$phpSerialize
$redisSerialize
MAX_TOKEN
ASYN_NAME
No protected methods found
$commands
$pool
$callBacks
$workerId
$server
$swooleServer
$token
$waitConnectNum
$asynManager
$redisMaxCount
N/A
No private methods found
$active
$coroutineRedisHelp
N/A

File
  Pools/RedisAsynPool.php
Package
  MSF\Pools
Class hierarchy
  \PG\MSF\Pools\AsynPool
  \PG\MSF\Pools\RedisAsynPool

## Tags

None found

## Constants

### MAX_TOKEN

    MAX_TOKEN

TOKEN最大值

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### ASYN_NAME

    ASYN_NAME

连接池类型名称

#

## Tags

None found

## Properties

### $config

    $config : \Noodlehaus\Config

#### Type

\Noodlehaus\Config — 配置对象

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $connect

    $connect : array

#### Type

array — 连接配置信息

#

## Tags

None found

### $redisClient

    $redisClient : \Redis

#### Type

\Redis — 同步Redis客户端

#

## Tags

None found

### $keyPrefix

    $keyPrefix : string

#### Type

string — Redis Key前缀

#

## Tags

None found

### $hashKey

    $hashKey : boolean

#### Type

boolean — 是否需要hash key

#

## Tags

None found

### $phpSerialize

    $phpSerialize : boolean

#### Type

boolean — 是否启用PHP序列化

#

## Tags

None found

### $redisSerialize

    $redisSerialize : boolean

#### Type

boolean — 是否启用Redis序列化

#

## Tags

None found

### $commands

    $commands : \SplQueue

#### Type

\SplQueue — 待执行命令队列

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $pool

    $pool : \SplQueue

#### Type

\SplQueue — 连接池

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $callBacks

    $callBacks : array

#### Type

array — 回调函数

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $workerId

    $workerId : integer

#### Type

integer — worker进程ID

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $server

    $server : \swoole_server

#### Type

\swoole_server — swoole_server实例

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $swooleServer

    $swooleServer : \PG\MSF\MSFServer

#### Type

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

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $token

    $token : integer

#### Type

integer — 回调Token

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $waitConnectNum

    $waitConnectNum : integer

#### Type

integer — 待连接数量

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $asynManager

    $asynManager : \PG\MSF\Pools\AsynPoolManager

#### Type

\PG\MSF\Pools\AsynPoolManager — 连接池管理器

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### $redisMaxCount

    $redisMaxCount : integer

#### Type

integer — 连接峰值

#

## Tags

None found

### $active

    $active : string

#### Type

string — 连接池标识

#

## Tags

None found

### $coroutineRedisHelp

    $coroutineRedisHelp : \PG\MSF\Pools\CoroutineRedisProxy

#### Type

\PG\MSF\Pools\CoroutineRedisProxy — 连接池辅助类

#

## Tags

None found

## Methods

### __construct()

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

RedisAsynPool constructor.

#### Parameters

\Noodlehaus\Config | $config | 配置对象
string | $active | 连接池名称

#### Throws

\Exception

#

## Tags

None found

### addTokenCallback()

    addTokenCallback(callable  $callback) : integer

注册回调

#### Parameters

callable | $callback | 回调函数

#### Returns

integer

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### distribute()

    distribute(array  $data) : $this

分发消息

#### Parameters

array | $data | 待分发数据

#### Returns

$this

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### 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

#

## Tags

None found

### workerInit()

    workerInit(integer  $workerId) : $this

初始化workerId

#### Parameters

integer | $workerId | worker进程ID

#### Returns

$this

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### pushToPool()

    pushToPool(mixed  $client) : $this

归还连接

#### Parameters

mixed | $client | 连接对象

#### Returns

$this

#

Inherited from
  \PG\MSF\Pools\AsynPool

## Tags

None found

### getSync()

    getSync() : \Redis

获取同步

#### Throws

\Exception

#### Returns

\Redis

#

## Tags

None found

### __call()

    __call(string  $name, array  $arguments)

__call魔术方法，映射redis方法

#### Parameters

string | $name | Redis指令
array | $arguments | Redis指令参数

#

## Tags

None found

### 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

#

## Tags

None found

### getCoroutine()

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

便捷协程模式

#### Returns

\Redis|\PG\MSF\Pools\coroutineRedisProxy

#

## Tags

None found

### execute()

    execute(array  $data)

执行Redis命令

#### Parameters

array | $data | Redis命令相关信息

#

## Tags

None found

### prepareOne()

    prepareOne()

创建一个Redis连接

#

## Tags

None found

### reconnect()

    reconnect(\swoole_redis|null  $client = null)

重连或者连接

#### Parameters

\swoole_redis|null | $client | 连接对象

#

## Tags

None found

### onClose()

    onClose(\swoole_redis  $client)

断开链接

#### Parameters

\swoole_redis | $client | 连接对象

#

## Tags

None found

### getAsynName()

    getAsynName() : string

返回唯一的连接池名称

#### Returns

string

#

## Tags

None found

### RedisAsynPool.php