/** * Store an item in the cache if the key does not exist. * * @param string $key * @param mixed $value * @param \DateTime|int $minutes * @return bool */ public function add($key, $value, $minutes) { if (method_exists($this->store, 'add')) { return $this->store->add($key, $value, $minutes); } if (is_null($this->get($key))) { $this->put($key, $value, $minutes); return true; } return false; }
/** * Store an item in the cache if the key does not exist. * * @param string $key * @param mixed $value * @param \DateTime|float|int $minutes * @return bool */ public function add($key, $value, $minutes) { $minutes = $this->getMinutes($minutes); if (is_null($minutes)) { return false; } if (method_exists($this->store, 'add')) { return $this->store->add($this->itemKey($key), $value, $minutes); } $exists = $this->get($key); if (is_null($exists) || $exists === false) { $this->put($key, $value, $minutes); return true; } return false; }
/** * Increment the login attempts for the user. * @param Request $request * @return int */ protected function incrementLoginAttempts(Request $request, Cache $cache) { $cache->add($key = $this->loginAttemptsKey($request), 1, 1); return (int) $cache->increment($key); }