Example #1
0
 /**
  * @param string|null $ip
  * @return Result
  */
 public function ip($ip = null)
 {
     if ($ip === null) {
         $ip = Yii::$app->request->getUserIP();
     }
     if (!array_key_exists($ip, $this->result)) {
         $key = self::className() . ':' . $ip;
         if ($this->session->offsetExists($key)) {
             $this->result[$ip] = $this->session->get($key);
         } else {
             $result = $this->reader->get($ip);
             $this->result[$ip] = new Result($result);
             $this->session->set($key, $this->result[$ip]);
         }
     }
     return $this->result[$ip];
 }