/** * Store the cache. * * @return void */ public function save() { $contents = $this->getForStorage(); if ($this->ttl !== null) { $this->client->put($this->key, $contents, $this->ttl); } else { $this->client->forever($this->key, $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; }
/** * 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; }
/** * Store an item in the cache indefinitely. * * @param string $key * @param mixed $value * @return void */ public function forever($key, $value) { $this->store->forever($this->taggedItemKey($key), $value); }
/** * Store an item in the cache indefinitely. * * @param string $key * @param mixed $value * @return void */ public function forever($key, $value) { $this->store->forever($key, $value); $this->fireCacheEvent('write', [$key, $value, 0]); }
/** * Reset the tag and return the new tag identifier. * * @param string $name * @return string */ public function resetTag($name) { $this->store->forever($this->tagKey($name), $id = str_replace('.', '', uniqid('', true))); return $id; }
/** * Store an item in the cache indefinitely. * * @param string $key * @param mixed $value * * @return void */ public function forever($key, $value) { $this->store->forever($key, $value); }