php 刷新 Laravel 4 中的所有缓存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18900969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Flush all cache in Laravel 4
提问by arielcr
Is there a way to flush all cache in Laravel 4? I'm using filefor caching. I read on the docs that you can use Cache::forget('key')
, but what if I need to delete all the cache?
有没有办法刷新 Laravel 4 中的所有缓存?我正在使用文件进行缓存。我阅读了您可以使用的文档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.
工匠命令也很有用,我认为 repo 上存在问题,但不确定它是否已实施。
Thanks!
谢谢!
回答by The Alpha
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();
回答by afroald
Illuminate\Cache\FileStore
has the function flush
, so you can use:
Illuminate\Cache\FileStore
有函数flush
,所以你可以使用:
Cache::flush();
回答by devo
Use,
用,
use Doctrine\Common\Cache\CacheProvider as DoctrineCache;
DoctrineCache::flushAll();
to flush all cache.
刷新所有缓存。