em = $em; $this->redis = $redis_client->getRedisClient(); } protected function getRiderKey($rider_id) { return self::RIDER_PREFIX_KEY . '.' . $rider_id; } public function getRiderLocation($rider_id) { $coordinates = new Point(0,0); $key = $this->getRiderKey($rider_id); // check redis cache for rider information if (($this->redis->hexists($key, 'longitude')) && ($this->redis->hexists($key, 'latitude'))) { $long = $this->redis->hget($key, 'longitude'); $lat = $this->redis->hget($key, 'latitude'); return new Point($long, $lat); } // not in cache, get hub $rider = $this->em->getRepository(Rider::class)->find($rider_id); $hub = $rider->getHub(); // no hub // TODO: return valid coordinate if ($hub == null) return new Point(0, 0); return $hub->getCoordinates(); } }