PHP code example of lulco / redis-proxy
1. Go to this page and download the library: Download lulco/redis-proxy library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lulco / redis-proxy example snippets
$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);
...
$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);
$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);
$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);
curl -sS https://getcomposer.org/installer | php
php composer.phar
php composer.phar update