Laravel 5 –清除共享主机服务器中的缓存 [英] Laravel 5 – Clear Cache in Shared Hosting Server
问题描述
问题很清楚.
php artisan cache:clear
是否有任何变通办法来清除缓存,就像上面我们在CLI中使用的缓存一样.我正在使用一种流行的共享主机服务,但是按照我的计划,我没有控制面板访问权限.
Is there any workaround to clear the cache like above we using in CLI. I am using a popular shared hosting service, but as per my plan, I don't have control panel access.
**我想清除视图缓存.**
** I want to clear the views cache.**
我看到了问题与此几乎相同,但事实并非如此帮帮我.
I saw a question almost the same as this, but it doesn't help me.
推荐答案
您可以在CLI外部调用Artisan命令.
You can call an Artisan command outside the CLI.
Route::get('/clear-cache', function() {
$exitCode = Artisan::call('cache:clear');
// return what you want
});
您可以在此处查看官方文档 http://laravel.com/docs/5.0/artisan#calling -commands-outside-of-cli
You can check the official doc here http://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli
更新
无法删除视图缓存. php artisan cache:clear
都不这样做.
There is no way to delete the view cache. Neither php artisan cache:clear
does that.
如果您真的想清除视图缓存,我认为您必须编写自己的artisan
命令并按我之前所说的那样调用它,或者完全跳过artisan
路径并在某些可以清除视图缓存的类中您是从控制器或路由呼叫的.
If you really want to clear the view cache, I think you have to write your own artisan
command and call it as I said before, or entirely skip the artisan
path and clear the view cache in some class that you call from a controller or a route.
但是,我真正的问题是您是否真的需要清除视图缓存?在我现在正在处理的项目中,我有近100个缓存的视图,它们的权重小于1 Mb,而我的vendor
目录为> 40 Mb.我不认为视图缓存是磁盘使用方面的真正瓶颈,也从未真正需要清除它.
But, my real question is do you really need to clear the view cache? In a project I'm working on now, I have almost 100 cached views and they weight less then 1 Mb, while my vendor
directory is > 40 Mb. I don't think view cache is a real bottleneck in disk usage and never had a real need to clear it.
关于应用程序缓存,它存储在storage/framework/cache
目录中,但前提是您在config/cache.php
中配置了file
驱动程序.您可以选择许多不同的驱动程序,例如 Redis 或 Memcached ,以提高基于文件的缓存的性能.
As for the application cache, it is stored in the storage/framework/cache
directory, but only if you configured the file
driver in config/cache.php
. You can choose many different drivers, such as Redis or Memcached, to improve performances over a file-based cache.
这篇关于Laravel 5 –清除共享主机服务器中的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!