Exemplo n.º 1
0
 private static function _getConnection($server)
 {
     if (!empty(self::$_connections[$server])) {
         return self::$_connections[$server];
     }
     $connection = new \Redis();
     try {
         $connection->connect($server);
         $connection->server = $server;
         self::$_connections[$server] = $connection;
     } catch (Exception $e) {
         \Tarth\Tool\Log::logger()->addError($e->getMessage());
     }
     return $connection;
 }
Exemplo n.º 2
0
 private static function _getConnection($server)
 {
     if (!empty(self::$_connections[$server])) {
         return self::$_connections[$server];
     }
     $connection = new \Redis();
     try {
         //Fix 'Redis::connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known' in docker php
         list($ip, $port) = explode(':', $server);
         $connection->connect($ip, $port);
         //$connection->connect($server);
         $connection->server = $server;
         self::$_connections[$server] = $connection;
     } catch (Exception $e) {
         \Tarth\Tool\Log::logger()->addError($e->getMessage());
     }
     return $connection;
 }
Exemplo n.º 3
0
 public function push($toQueue = false)
 {
     try {
         if ($toQueue == false) {
             $runTimeInFuture = $this->_runAtFuture();
         } else {
             $runTimeInFuture = false;
         }
         if ($runTimeInFuture) {
             if (Redis::queueRedis()->rPush('tarth-timer-' . $runTimeInFuture, (string) $this)) {
                 return $this->id;
             }
         } else {
             if (Redis::queueRedis()->rPush('tarth-queue-' . $this->priority, (string) $this)) {
                 return $this->id;
             }
         }
     } catch (Exception $e) {
         Log::logger()->addError($e->getMessage);
     }
     return false;
 }