Ejemplo n.º 1
0
Archivo: Fetch.php Proyecto: vucms/aha
 public function redisDemo($dispatcher)
 {
     $config = $dispatcher->getBootstrap()->getConfig();
     $instanceName = 'test';
     $conf = $config->get('redis', $instanceName);
     $conn = \Aha\Storage\Memory\Pool::getConnection($instanceName, $conf);
     $res1 = (yield $conn->createCoroutine()->hmset('ms', array('a' => '12345', 'b' => 'wqerty')));
     $res2 = (yield $conn->createCoroutine()->hmget('ms', array('a', 'b')));
     $res3 = (yield $conn->createCoroutine()->hgetall('ms'));
     (yield compact('res1', 'res2', 'res3'));
 }
Ejemplo n.º 2
0
Archivo: Rdb.php Proyecto: vucms/aha
 public function excute()
 {
     $config = $this->_objDispatcher->getBootstrap()->getConfig();
     $instanceName = 'test';
     $conf = $config->get('redis', $instanceName);
     $conn = \Aha\Storage\Memory\Pool::getConnection($instanceName, $conf);
     //$conn->zadd('sortedSet', 10, 'aaaa', 20, 'bbbbb', array($this, 'QueryCallback'));
     //$conn->zrange('sortedSet',0, -1, 'WITHSCORES',array($this, 'QueryCallback'));
     //$conn->sadd('settest', 10, 'aaaa', 20, 'bbbbb', array($this, 'QueryCallback'));
     //$conn->smembers('settest', array($this, 'QueryCallback'));
     //$conn->rpush('listtest', 12, 'aaaa', 27, 'bbbbb', array($this, 'QueryCallback'));
     //$conn->lrange('listtest', 0, -1, array($this, 'QueryCallback'));
     //$conn->hmset('ms',  array('a'=>'12345','b'=>'wqerty'), array($this, 'QueryCallback'));
     //$conn->hmget('ms',  array('a','b'), array($this, 'QueryCallback'));
     //$conn->hgetall('ms', array($this, 'QueryCallback'));
     //$conn->set('setA',  str_repeat('A', 20), array($this, 'QueryCallback'));
     //$conn->mset('setB',  str_repeat('B', 20), 'setC', str_repeat('C', 20), array($this, 'QueryCallback'));
     //$conn->mget('setB', 'setC', array($this, 'QueryCallback'));
     $conn->get('setA', array($this, 'QueryCallback'));
 }
Ejemplo n.º 3
0
 /**
  * @brief redis响应数据回调上层和资源回收
  * @param type $result
  * @param type $callback
  */
 public function response($result, $callback, \Aha\Storage\Memory\Rediscli $redisCli, $error = null)
 {
     try {
         call_user_func($callback, $result, $error);
     } catch (\Exception $e) {
         echo "Redis Response Callback Exception: {$e->getMessage()}" . PHP_EOL;
     }
     //如果此连接已经关闭 放入回收器 等待触发资源回收
     if (!$redisCli->getClient()->isConnected()) {
         $this->_connectionNum--;
         \Aha\Storage\Memory\Pool::redisCliGc($redisCli);
         return $this->_trigger();
     }
     //未关闭则当作长连接放入连接池
     $this->_idlePool[] = $redisCli;
     return $this->_trigger();
 }