/** * Returns the current cache instance * * @param array $tags * * @return Cache */ protected function getCache(array $tags) { if ($this->cache instanceof TaggableStore) { return $this->cache->tags(array_merge(['russian'], $tags)); } return $this->cache; }
/** * Return the cache instance with tags attached. * * @return \Illuminate\Contracts\Cache\Repository|\Illuminate\Contracts\Cache\Store */ protected function cache() { if (!method_exists($this->cache, 'tags')) { return $this->cache; } return $this->cache->tags($this->tag); }
/** * Execute the query as a "select" statement. * * @param array $columns * @return array|static[] */ public function get($columns = ['*']) { $cacheKey = $this->generateCacheKey(); if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) { $results = parent::get($columns); $this->cache->tags($this->cacheTag)->forever($cacheKey, $results); } return $results; }
/** * @param $name * * @return Sidebar */ public function resolve($name) { if ((new SupportsCacheTags())->isSatisfiedBy($this->cache)) { $userId = $this->guard->check() ? $this->guard->user()->getAuthIdentifier() : null; $duration = $this->config->get('sidebar.cache.duration'); return $this->cache->tags(CacheKey::get($name))->remember(CacheKey::get($name, $userId), $duration, function () use($name) { return $this->resolver->resolve($name); }); } }
public function handle() { try { $configs = $this->config->get('acl'); $this->permissionManager->deleteAllPermissions(); $this->cache->forget($configs['acl.permission_cache_key']); $this->cache->tags($configs['acl.user_permissions_cache_key'])->flush(); $this->info('All permissions are deleted from database and cache'); } catch (\Exception $e) { $this->error($e->getMessage()); } }
/** * Execute the query as a "select" statement. * All Cached results will be flushed after every CUD operations * * @param array $columns * @return array|static[] */ public function get($columns = ['*']) { $cacheKey = $this->generateCacheKey(); if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) { $results = parent::get($columns); if ($this->isTimeAwareQuery) { // Cache results for $cacheLifeTime minutes $this->cache->tags($this->cacheTag)->put($cacheKey, $results, $this->cacheLifeTime); } else { // Cache results forever $this->cache->tags($this->cacheTag)->forever($cacheKey, $results); } } return $results; }
/** * Execute the console command. * * @return mixed */ public function handle(Cache $cache) { $ips = $this->fetchExitNodeIPs()->map(function ($ip) use($cache) { $cache->tags(config('torinfo.caching.tags'))->put($ip, true, config('torinfo.caching.expiry')); return $ip; }); }
/** * Flush all of the provided keys from the cache. This can be useful if * you want to remove all of one type, not just where it is associated * with a cacheable item. * * i.e. The sidebar items are cached against the user's and you want * to remove all of the sidebar items. * * @param array|string $keys * @return mixed */ public function flushKeys($keys) { if (!is_array($keys)) { $keys = func_get_args(); } return $this->cache->tags($keys)->flush(); }
/** * Empty all views linked to a tag or the complete partial cache. * Note: Only supported by Taggable cache drivers. * * @param string $tag * * @throws \Spatie\PartialCache\Exceptions\MethodNotSupportedException */ public function flush($tag = null) { if (!$this->cacheIsTaggable) { throw new MethodNotSupportedException('The cache driver (' . get_class($this->cacheManager->driver()) . ') doesn\'t support the flush method.'); } $tag = $tag ?: $this->cacheKey; $this->cache->tags($tag)->flush(); }
/** * Detect as best we can whether tags are supported with this repository & store, * and save our result on the $supportsTags flag. * * @return void */ protected function determineTagSupport() { // Laravel >= 5.1.28 if (method_exists($this->cache, 'tags')) { try { // Attempt the repository tags command, which throws exceptions when unsupported $this->cache->tags($this->tag); $this->supportsTags = true; } catch (BadMethodCallException $ex) { $this->supportsTags = false; } } else { // Laravel <= 5.1.27 if (method_exists($this->cache, 'getStore')) { // Check for the tags function directly on the store $this->supportsTags = method_exists($this->cache->getStore(), 'tags'); } else { // Must be using custom cache repository without getStore(), and all bets are off, // or we are mocking the cache contract (in testing), which will not create a getStore method $this->supportsTags = false; } } }
public function handle() { $this->cache->tags('setting.settings')->flush(); }
public function update($id, array $attribute) { if ($this->model->update($id, $attribute)) { $this->cache->tags($this->baseCacheKey)->flush(); } }
/** * Check if the given key exists in the cache. * * @param mixed $key */ public function has($key) { $key = $this->normalizeCacheKey($key); return $this->cache->tags('views')->has($key); }
/** * Update all menu items * @param Request $request */ public function update(Request $request) { $this->cache->tags('menuItems')->flush(); $this->menuOrdener->handle($request->get('menu')); }
/** * @author Morteza Parvini <*****@*****.**> * @param UserInterface $user * @param $key * @return array */ protected function getUserPermissionsFromCache(UserInterface $user, $key) { return $this->cache->tags('acl_users')->get($this->getUserPermissionCacheKey($user)); }
/** * Clear cached queries * @return void */ protected function clearCache() { $this->cache->tags($this->generateCacheTag())->flush(); }