简体   繁体   English

刷新Laravel 4中的所有缓存

[英]Flush all cache in Laravel 4

Is there a way to flush all cache in Laravel 4? 有没有办法刷新Laravel 4中的所有缓存? I'm using file for caching. 我正在使用文件进行缓存。 I read on the docs that you can use Cache::forget('key') , but what if I need to delete all the cache? 我在文档上看到你可以使用Cache::forget('key') ,但如果我需要删除所有缓存怎么办?

An artisan command can also be useful, I think there's an issue on the repo, but not sure if it's implemented yet. 工匠命令也很有用,我认为回购上有一个问题,但不确定它是否已经实现。

Thanks! 谢谢!

If you run php artisan list then you can find all the commands available for artisan , anyways, there is a command to clear the cache and it's 如果你运行php artisan list然后你可以找到artisan可用的所有命令,无论如何,有一个清除cache的命令,它是

php artisan cache:clear

Also, you can use 另外,你可以使用

foreach (Cache::getMemory() as $cacheKey => $cacheValue)
{

    Cache::forget($cacheKey);
}

Update: 更新:

Cache::flush();

Illuminate\\Cache\\FileStore具有flush功能,因此您可以使用:

Cache::flush();

Use, 使用,

use Doctrine\Common\Cache\CacheProvider as DoctrineCache;

DoctrineCache::flushAll();

to flush all cache. 刷新所有缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM