lulco / redis-proxy
Library for Redis driver abstraction
Installs: 120 544
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 4
Open Issues: 0
Requires
- php: ^7.4 | ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.5.20
- predis/predis: ^1.1 | ^2.0
Suggests
- ext-redis: Native PHP extension for Redis connectivity.
- predis/predis: Flexible and feature-complete PHP client library for Redis https://github.com/nrk/predis/wiki
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);