php redis客户端配置-PHP-IT技术博客

php redis客户端配置

时间:2019-08-17 13:26:44 浏览: 字体: 放大 缩小


Many aspects and behaviors of the client can be configured by passing specific client options to the second argument of Predis\Client::__construct():

可以通过Predis\Client::__construct()的第二个参数,来配置客户端的许多属性,如下面的Redis的2.8版本,前缀为sample:

$client = new Predis\Client($parameters, ['profile' => '2.8', 'prefix' => 'sample:']);

Options are managed using a mini DI-alike container and their values can be lazily initialized only when needed. The client options supported by default in Predis are:

选项使用mini DI-alike的容器进行管理,只有在需要时才可以延迟地初始化它们的值。 Predis中默认支持的客户端选项是:


profile: specifies the profile to use to match a specific version of Redis.

profile:指定用于匹配特定版本Redis的配置文件。


prefix: prefix string automatically applied to keys found in commands.

prefix:前缀字符串自动应用于命令中的键。


exceptions: whether the client should throw or return responses upon Redis errors.

exceptions:客户端是否应该在Redis错误时抛出或返回响应。


connections: list of connection backends or a connection factory instance.

connections:连接后端列表或连接工厂实例。


cluster: specifies a cluster backend (predis, redis or callable object).

cluster:指定集群后端(predis,redis或callable对象)。


replication: specifies a replication backend (TRUE, sentinel or callable object).

replication:指定复制后端(TRUE,sentinel或callable对象)。


aggregate: overrides cluster and replication to provide a custom connections aggregator.

aggregate:覆盖群集和复制以提供自定义连接聚合器。


parameters: list of default connection parameters for aggregate connections.

parameters:聚合连接的默认连接参数列表。


Users can also provide custom options with values or callable objects (for lazy initialization) that are stored in the options container for later use through the library.

用户还可以提供带有值或可调用对象(用于延迟初始化)的自定义选项,这些对象存储在选项容器中供以后通过库使用。





标签: Redisphp客户端配置