/** * {@inheritdoc} */ protected function clearOneObjectFromCache($key) { if (null === $this->store->get($key)) { return true; } return $this->store->forget($key); }
/** * Load the cache. * * @return void */ public function load() { $contents = $this->client->get($this->key); if ($contents !== null) { $this->setFromStorage($contents); } }
/** * Get the given user's permissions. * * @param \Illuminate\Database\Eloquent\Model $user * @return \Illuminate\Database\Eloquent\Collection */ public function getPermissions(Model $user) { $key = $this->tag . '-permissions-' . $user->getKey(); if ($permissions = $this->cache->get($key)) { return $this->deserializePermissions($permissions); } $permissions = parent::getPermissions($user); $this->cache->forever($key, $this->serializePermissions($permissions)); return $permissions; }
/** * Get the given user's abilities. * * @param \Illuminate\Database\Eloquent\Model $user * @return \Illuminate\Database\Eloquent\Collection */ public function getAbilities(Model $user) { $key = $this->tag . '-abilities-' . $user->getKey(); if ($abilities = $this->cache->get($key)) { return $this->deserializeAbilities($abilities); } $abilities = parent::getAbilities($user); $this->cache->forever($key, $this->serializeAbilities($abilities)); return $abilities; }
/** * Retrieve an item from the cache by key. * * @param string $key * @param mixed $default * @return mixed */ public function get($key, $default = null) { $value = $this->store->get($key); if (is_null($value)) { $this->fireCacheEvent('missed', [$key]); $value = value($default); } else { $this->fireCacheEvent('hit', [$key, $value]); } return $value; }
/** * Get an item from the cache, or store the default value forever. * * @param string $key * @param callable $callback * @return mixed */ protected function sear($key, callable $callback) { if (is_null($value = $this->cache->get($key))) { $this->cache->forever($key, $value = $callback()); } return $value; }
/** * Get the throttle hit count. * * @return int */ public function count() { if ($this->number !== null) { return $this->number; } $this->number = (int) $this->store->get($this->key); if (!$this->number) { $this->number = 0; } return $this->number; }
/** * Retrieve an item from the cache by key. * * @param string $key * @param mixed $default * @return mixed */ public function get($key, $default = null) { if (is_array($key)) { return $this->many($key); } $value = $this->store->get($this->itemKey($key)); if (is_null($value) || $value === false) { $this->fireCacheEvent('missed', [$key]); $value = value($default); } else { $this->fireCacheEvent('hit', [$key, $value]); } return $value; }
/** * {@inheritdoc} */ public function contains($key) { return $this->cache->get($key) !== null; }
/** * Retrieve an item from the cache by key. * * @param string|array $key * @param mixed $default * @return mixed */ public function get($key, $default = null) { $value = $this->store->get($this->taggedItemKey($key)); return !is_null($value) ? $value : value($default); }
/** * Get the unique tag identifier for a given tag. * * @param string $name * @return string */ public function tagId($name) { return $this->store->get($this->tagKey($name)) ?: $this->resetTag($name); }
/** * Get an item from the cache * * @param string $key * @return mixed */ public function get($key) { return $this->store->get($key); }
/** * Redirect the user after determining they are locked out. * @param Request $request * @return \Illuminate\Http\RedirectResponse */ protected function sendLockoutResponse(Request $request, Cache $cache) { $seconds = (int) $cache->get($this->loginLockExpirationKey($request)) - time(); return redirect($this->loginUrl())->withInput($request->only('username', 'remember'))->withErrors(['username' => trans('passwords.throttle', ['seconds' => $seconds])]); }
/** * Get an item from the cache * * @param string $locale * @param string $group * @param string $namespace * @return mixed */ public function get($locale, $group, $namespace) { $key = $this->getKey($locale, $group, $namespace); return $this->store->get($key); }