Laravel 5 – Clear Cache in Shared Hosting Server(Laravel 5 – 清除共享托管服务器中的缓存)
问题描述
问题很清楚.
php artisan cache:clear
是否有任何解决方法可以像上述命令一样清除缓存,但不使用 CLI.我使用的是流行的共享托管服务,但根据我的计划,我没有控制面板访问权限.
Is there any workaround to clear the cache like the above command but without using CLI. I am using a popular shared hosting service, but as per my plan, I don't have control panel access.
我想清除视图缓存.
我看到一个问题 几乎与此相同,但它没有帮帮我.
I saw a question almost the same like 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
path 并清除您从控制器或路由调用的某个类中的视图缓存.
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
目录下,但前提是你配置了file
驱动在 config/cache.php
中.您可以选择许多不同的驱动程序,例如 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 – 清除共享托管服务器中的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Laravel 5 – 清除共享托管服务器中的缓存
基础教程推荐
- HTTP 与 FTP 上传 2021-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 使用 PDO 转义列名 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01