本文整理汇总了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));
}
}
示例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);
});
}
}
示例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();
});
}
示例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);
});
}
示例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;
}
示例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());
}
}
示例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;
});
}
示例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);
}
示例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;
}
示例10: clear
public function clear()
{
//clear database
$this->storage->clear();
// clear cached options
$this->cache->forget('weboap.options');
}
示例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);
}
示例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());
}
}
示例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);
}
示例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());
}
}
示例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());
}
}