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; }
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; }
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; }