当前位置: 首页>>代码示例>>PHP>>正文


PHP Repository::forget方法代码示例

本文整理汇总了PHP中Illuminate\Contracts\Cache\Repository::forget方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::forget方法的具体用法?PHP Repository::forget怎么用?PHP Repository::forget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Contracts\Cache\Repository的用法示例。


在下文中一共展示了Repository::forget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 public function update($id, array $attribute)
 {
     if ($this->model->update($id, $attribute)) {
         $this->cache->forget($this->getKey('all'));
         $this->cache->forget($this->getKey('id-' . $id));
     }
 }
开发者ID:ShuvarthiDhar,项目名称:tobacco,代码行数:7,代码来源:BaseCache.php

示例2: __call

 /**
  *
  */
 public function __call($method, $params)
 {
     if (!method_exists($this->repository, $method)) {
         throw new RepositoryException("Method {$method} not found on repository");
     }
     if ($this->skipCache === true || config('laravel-database.cache') === false) {
         return call_user_func_array(array($this->repository, $method), $params);
     } else {
         if (empty($this->key)) {
             $this->cacheKey($this->generateKey($method, $params));
         }
         $key = $this->key;
         unset($this->key);
         if ($this->refreshCache) {
             $this->cache->forget($key);
             $this->refreshCache = false;
         }
         if (empty($this->lifetime)) {
             $this->cacheLifetime($this->repository->getModel()->cacheLifetime());
         }
         $lifetime = $this->lifetime;
         unset($this->lifetime);
         return $this->cache->remember($key, $lifetime, function () use($method, $params) {
             return call_user_func_array(array($this->repository, $method), $params);
         });
     }
 }
开发者ID:ablunier,项目名称:laravel-database,代码行数:30,代码来源:Cache.php

示例3: roles

 /**
  * @param bool $forget
  *
  * @return \Illuminate\Database\Eloquent\Collection|Role[]|null
  */
 public function roles(bool $forget = false)
 {
     if ($forget === true) {
         return $this->cache->forget(self::ROLE_KEY);
     }
     return $this->cache->rememberForever(self::ROLE_KEY, function () {
         return app(Role::class)->with('permissions')->get();
     });
 }
开发者ID:znck,项目名称:trust,代码行数:14,代码来源:Trust.php

示例4: performQuery

 /**
  * Query the Google Analytics Service with given parameters.
  *
  * @param string    $viewId
  * @param \DateTime $startDate
  * @param \DateTime $endDate
  * @param string    $metrics
  * @param array     $others
  *
  * @return array|null
  */
 public function performQuery(string $viewId, DateTime $startDate, DateTime $endDate, string $metrics, array $others = [])
 {
     $cacheName = $this->determineCacheName(func_get_args());
     if ($this->cacheLifeTimeInMinutes == 0) {
         $this->cache->forget($cacheName);
     }
     return $this->cache->remember($cacheName, $this->cacheLifeTimeInMinutes, function () use($viewId, $startDate, $endDate, $metrics, $others) {
         return $this->service->data_ga->get("ga:{$viewId}", $startDate->format('Y-m-d'), $endDate->format('Y-m-d'), $metrics, $others);
     });
 }
开发者ID:spatie,项目名称:laravel-analytics,代码行数:21,代码来源:AnalyticsClient.php

示例5: __call

 /**
  * @param $name
  * @param $arguments
  * @return mixed
  */
 public function __call($name, $arguments)
 {
     /*
      * simple strategy: for any database altering method we do the following:
      * - call the parent method
      * - bust the cache
      */
     $result = call_user_func_array([$this->menu, $name], $arguments);
     $this->cache->forget('menus');
     return $result;
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:16,代码来源:CachedMenuRepository.php

示例6: handle

 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());
     }
 }
开发者ID:morilog,项目名称:acl,代码行数:12,代码来源:ClearPermissions.php

示例7: get

 /**
  * Get the given documentation page.
  *
  * @param  string  $version
  * @param  string  $page
  * @return string
  */
 public function get($version, $page)
 {
     // If the enviroment is local forget the cache
     if (app()->environment() == 'local') {
         $this->cache->forget('docs.' . $version . '.' . $page);
     }
     return $this->cache->remember('docs.' . $version . '.' . $page, 5, function () use($version, $page) {
         $path = base_path('resources/docs/' . $version . '/' . $page . '.md');
         if ($this->files->exists($path)) {
             return $this->replaceLinks($version, markdown($this->files->get($path)));
         }
         return null;
     });
 }
开发者ID:vexilo,项目名称:laravel.lat,代码行数:21,代码来源:Documentation.php

示例8: recountForums

 private function recountForums()
 {
     $this->info('Recounting forum counters...');
     // We're calling the model directly to avoid caching issues
     $forums = Forum::all();
     foreach ($forums as $forum) {
         // We need the topics later to calculate the post number and the last post
         $topics = Topic::where('forum_id', '=', $forum->id)->orderBy('created_at', 'desc');
         $forum->num_topics = $topics->count();
         $numPosts = 0;
         $lastPost = null;
         $lastPostUser = null;
         foreach ($topics->get() as $topic) {
             $numPosts += $topic->num_posts;
             // We can simply override this variable all the time.
             // The topics are sorted so the last time we override this we have our last post
             $lastPost = $topic->last_post_id;
             $lastPostUser = $topic->lastPost->user_id;
         }
         $forum->num_posts = $numPosts;
         $forum->last_post_id = $lastPost;
         $forum->last_post_user_id = $lastPostUser;
         $forum->save();
     }
     // Override our old cache to populate our new numbers
     $this->cache->forever('forums.all', $forums);
     // We could also recache this cache but the recount tool is already busy
     // so probably better to leave it to the first user
     $this->cache->forget('forums.index_tree');
     $this->info('Done' . PHP_EOL);
 }
开发者ID:Adamzynoni,项目名称:mybb2,代码行数:31,代码来源:RecountCommand.php

示例9: save

 /**
  * {@inheritdoc}
  */
 public function save(CacheItemInterface $item)
 {
     $expiresAt = $this->getExpiresAt($item);
     if (!$expiresAt) {
         try {
             $this->repository->forever($item->getKey(), serialize($item->get()));
         } catch (Exception $exception) {
             return false;
         }
         return true;
     }
     $now = new DateTimeImmutable('now', $expiresAt->getTimezone());
     $seconds = $expiresAt->getTimestamp() - $now->getTimestamp();
     $minutes = (int) floor($seconds / 60.0);
     if ($minutes <= 0) {
         $this->repository->forget($item->getKey());
         return false;
     }
     try {
         $this->repository->put($item->getKey(), serialize($item->get()), $minutes);
     } catch (Exception $exception) {
         return false;
     }
     return true;
 }
开发者ID:madewithlove,项目名称:illuminate-psr-cache-bridge,代码行数:28,代码来源:CacheItemPool.php

示例10: clear

 public function clear()
 {
     //clear database
     $this->storage->clear();
     // clear cached options
     $this->cache->forget('weboap.options');
 }
开发者ID:weboap,项目名称:option,代码行数:7,代码来源:Option.php

示例11: forget

 /**
  * Forget a rendered view.
  *
  * @param string $view
  * @param string $key
  */
 public function forget($view, $key = null)
 {
     $cacheKey = $this->getCacheKeyForView($view, $key);
     if ($this->cacheIsTaggable) {
         $this->cache->tags($this->cacheKey)->forget($cacheKey);
     }
     $this->cache->forget($cacheKey);
 }
开发者ID:spatie,项目名称:laravel-partialcache,代码行数:14,代码来源:PartialCache.php

示例12: save

 /**
  * Save the changes.
  *
  * @param  \Illuminate\Database\Eloquent\Collection  $saved
  * @param  array                                     $changes
  */
 public function save($saved, array $changes)
 {
     $this->setSaved($saved);
     $this->saveInserted($changes['inserted']);
     $this->saveUpdated($changes['updated']);
     $this->saveDeleted($changes['deleted']);
     if ($this->isCached()) {
         $this->cache->forget($this->getCacheKey());
     }
 }
开发者ID:ARCANESOFT,项目名称:Settings,代码行数:16,代码来源:EloquentStore.php

示例13: forget

 /**
  * Forget current setting value.
  *
  * @param string $key
  * @return void
  */
 public function forget($key)
 {
     $this->fire('forgetting', $key, [$key]);
     $generatedKey = $this->getKey($key);
     $this->repository->forget($generatedKey);
     if ($this->isCacheEnabled()) {
         $this->cache->forget($generatedKey);
     }
     $this->fire('forget', $key, [$key]);
     $this->context(null);
 }
开发者ID:sylarbg,项目名称:settings,代码行数:17,代码来源:Settings.php

示例14: handle

 /**
  * @param RepositoryEventBase $event
  */
 public function handle(RepositoryEventBase $event)
 {
     try {
         $cleanEnabled = config("repository.cache.clean.enabled", true);
         if ($cleanEnabled) {
             $this->repository = $event->getRepository();
             $this->model = $event->getModel();
             $this->action = $event->getAction();
             if (config("repository.cache.clean.on.{$this->action}", true)) {
                 $cacheKeys = CacheKeys::getKeys(get_class($this->repository));
                 if (is_array($cacheKeys)) {
                     foreach ($cacheKeys as $key) {
                         $this->cache->forget($key);
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         Log::error($e->getMessage());
     }
 }
开发者ID:olefirenko,项目名称:l5-repository,代码行数:24,代码来源:CleanCacheRepository.php

示例15: run

 /**
  * Run the given event.
  *
  * @param  \Illuminate\Contracts\Container\Container  $container
  * @return void
  */
 public function run(Container $container)
 {
     if ($this->withoutOverlapping) {
         $this->cache->put($this->mutexName(), true, 1440);
     }
     if (!$this->runInBackground) {
         $this->runCommandInForeground($container);
     } else {
         $this->runCommandInBackground();
     }
     if ($this->withoutOverlapping) {
         $this->cache->forget($this->mutexName());
     }
 }
开发者ID:rosswilson252,项目名称:framework,代码行数:20,代码来源:Event.php


注:本文中的Illuminate\Contracts\Cache\Repository::forget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。