Пример #1
0
 public static function init()
 {
     Driver::$DRIVER_ATTRIBUTE_KEYS = array(RegionBasedEntity::LATITUDE_KEY, RegionBasedEntity::LONGITUDE_KEY, RegionBasedEntity::REGION_KEY);
 }
Пример #2
0
 /**
  * Looks up driver details in cache.
  *
  * Performance: O(1) time complexity (constant time)
  *
  * @param $driverId int id of driver to look up details for
  * @return bool|Driver  returns false if driver doesn't exist in the cache,
  *                      otherwise it returns a Driver model instance containing driver details
  */
 public function lookupDriver($driverId)
 {
     if (!is_int($driverId)) {
         throw new InvalidArgumentException("lookupDriver expects driver id to be an integer. Input was: {$driverId}");
     }
     $driverId = intval($driverId);
     if (!$this->client->exists(self::driverPath($driverId))) {
         return false;
     }
     //O(1) time complexity
     $values = $this->client->hmget(self::driverPath($driverId), Driver::$DRIVER_ATTRIBUTE_KEYS);
     return Driver::fromValues($driverId, $values);
 }