Exemplo n.º 1
0
 public function testX()
 {
     return;
     $config = ['default' => ['host' => '127.0.0.1', 'port' => 6379, 'timeout' => 5, 'reserved' => null, 'retry_interval' => 100]];
     $pool = RedisPool::init($config);
     $reids = $pool->getRedis();
     $rst = $pool->getRedis()->set('testunit_1', 'xxx');
     var_dump($rst);
     exec('service redis-server stop', $output, $code);
     var_dump($output, $code);
     try {
         $rst = $pool->getRedis()->set('testunit_1', 'xxx');
     } catch (\Exception $e) {
         var_dump($e->getMessage(), $e->getCode());
     }
 }
Exemplo n.º 2
0
 public function redis($group = 'default', $slave = false)
 {
     $id = '_.redis';
     if (!isset($this->container[$id])) {
         $this->container[$id] = RedisPool::init($this->config('redis'));
     }
     if ($slave) {
         return $this->container[$id]->getRedisSlave($group);
     }
     return $this->container[$id]->getRedis($group);
 }