沃梦达 / 编程问答 / php问题 / 正文

Laravel 5 – 清除共享托管服务器中的缓存

Laravel 5 – Clear Cache in Shared Hosting Server(Laravel 5 – 清除共享托管服务器中的缓存)

本文介绍了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:cleardoes that.

如果你真的想清除视图缓存,我认为你必须编写自己的artisan命令并像我之前所说的那样调用它,或者完全跳过artisanpath 并清除您从控制器或路由调用的某个类中的视图缓存.

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 中.您可以选择许多不同的驱动程序,例如 RedisMemcached,以提高基于文件的缓存的性能.

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 – 清除共享托管服务器中的缓存

基础教程推荐