# redis-sentinel-php **Repository Path**: mirrors/redis-sentinel-php ## Basic Information - **Project Name**: redis-sentinel-php - **Description**: 基于 phpredis 扩展的 redis-sentinel 客户端 - **Primary Language**: PHP - **License**: Not specified - **Default Branch**: master - **Homepage**: https://www.oschina.net/p/redis-sentinel-php - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-26 - **Last Updated**: 2025-12-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # redis-sentinel [![Latest Stable Version](https://poser.pugx.org/jenner/redis_sentinel/v/stable)](https://packagist.org/packages/jenner/simple_fork) [![Total Downloads](https://poser.pugx.org/jenner/redis_sentinel/downloads)](https://packagist.org/packages/jenner/simple_fork) [![Latest Unstable Version](https://poser.pugx.org/jenner/redis_sentinel/v/unstable)](https://packagist.org/packages/jenner/simple_fork) [![License](https://poser.pugx.org/jenner/redis_sentinel/license)](https://packagist.org/packages/jenner/simple_fork) [![travis](https://travis-ci.org/huyanping/redis-sentinel.svg)](https://travis-ci.org/huyanping/simple-fork-php) redis-sentinel client for php based on phpredis extension. ## examples Get Redis master address and create Redis object: ```php $sentinel = new \Jenner\RedisSentinel\Sentinel(); $sentinel->connect('127.0.0.1', 6379); $address = $sentinel->getMasterAddrByName('mymaster'); $redis = new Redis(); $redis->connect($address['ip'], $address['port']); $info = $redis->info(); print_r($info); ``` Create redis-sentinel pool and create Redis object: ```php $sentinel_pool = new \Jenner\RedisSentinel\SentinelPool(); $sentinel_pool->addSentinel('127.0.0.1', 26379); $sentinel_pool->addSentinel('127.0.0.1', 26380); $address = $sentinel_pool->master('mymaster'); print_r($address); $redis = $sentinel_pool->getRedis('mymaster'); $info = $redis->info(); print_r($info); ``` In order to prevent redis/sentinel to wait too long for connections in case of issues with the Redis backend it's advisable to use a timeout (in seconds): ```php $sentinel_pool->addSentinel('127.0.0.1', 26380, 1.0); # 1 second timeout ```