lulco/redis-proxy
最新稳定版本:1.7.0
Composer 安装命令:
composer require lulco/redis-proxy
包简介
Library for Redis driver abstraction
README 文档
README
Library for creating redis instance depends on application / server possibilities
Installation
Composer
The fastest way to install Redis proxy is to add it to your project using Composer (http://getcomposer.org/).
- Install Composer:
curl -sS https://getcomposer.org/installer | php - Require Redis proxy as a dependency using Composer:
php composer.phar require lulco/redis-proxy - Install Redis proxy:
php composer.phar update
Usage
Single redis node
$redis = new \RedisProxy\RedisProxy($host, $port); // Call redis methods $redis->select($database); $redis->hset($key, $field, $value); $redis->hlen($key); $redis->hget($key, $field); $redis->hgetall($key); ...
Sentinel
$sentinels = [ ['host' => '172.19.0.5', 'port' => 26379], ['host' => '172.19.0.6', 'port' => 26379], ['host' => '172.19.0.7', 'port' => 26379], ]; $clusterId = 'mymaster'; $redis = new \RedisProxy\RedisProxy(); $redis->setSentinelConnectionPool($sentinels, $clusterId, $database); // Call redis methods $redis->hset($key, $field, $value); $redis->hlen($key); $redis->hget($key, $field); $redis->hgetall($key);
Multi read connection
Read from multiple redis nodes Write to one master redis node
$master = ['host' => '172.19.0.5', 'port' => 26379]; $slaves = [ ['host' => '172.19.0.5', 'port' => 26379], ['host' => '172.19.0.6', 'port' => 26379], ['host' => '172.19.0.7', 'port' => 26379], ]; $clusterId = 'mymaster'; $redis = new \RedisProxy\RedisProxy(); $redis->setMultiConnectionPool($master, $slaves);
Multi write connection
Write to multiple master redis nodes Optionally read from multiple redis nodes
$masters = [ ['host' => '172.19.0.5', 'port' => 26379], ['host' => '172.19.0.6', 'port' => 26379], ['host' => '172.19.0.7', 'port' => 26379], ]; $slaves = [ ['host' => '172.19.0.5', 'port' => 26379], ['host' => '172.19.0.6', 'port' => 26379], ['host' => '172.19.0.7', 'port' => 26379], ]; $clusterId = 'mymaster'; $redis = new \RedisProxy\RedisProxy(); $redis->setMultiWriteConnectionPool($masters, $slaves);
统计信息
- 总下载量: 154.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-22