如何正确地使Symfony2应用程序的生产缓存无效?

时间:2021-07-07 03:52:27

I changed the configuration of the application and deployed the new code to production server. Since the application does not parse the configuration files and use precompiled classes I needed to update the cache files.

我更改了应用程序的配置并将新代码部署到生产服务器。由于应用程序不解析配置文件并使用预编译类,我需要更新缓存文件。

There is app/console cache:warmup and app/console cache:clear commands. But the cache wasn't updated after invoking these commands, so I had to delete the app/cache folder manually.

有app / console cache:warmup和app / console cache:clear命令。但是在调用这些命令后缓存没有更新,所以我不得不手动删除app / cache文件夹。

Manual deletion is very dangerous operation because it's not atomic so I can remove part of cache during request and this may lead to fatal error.

手动删除是非常危险的操作,因为它不是原子的,所以我可以在请求期间删除部分缓存,这可能会导致致命错误。

How should I reload cache?

我该如何重新加载缓存?

3 个解决方案

#1


24  

You missed env parameter: app/console cache:clear --env=prod --no-debug

你错过了env参数:app / console cache:clear --env = prod --no-debug

#2


1  

i believe you can try app/console cache:clear --no-warmup

我相信你可以试试app / console cache:clear --no-warmup

#3


0  

To clear the cache and instantly access the data my fix is

要清除缓存并立即访问我的修复数据

sudo app/console cache:clear --env=prod --no-warmup --no-debug

using this command turns off debug, and doesn't have a warmup time before the data is accessible again

使用此命令将关闭调试,并且在再次访问数据之前没有预热时间

#1


24  

You missed env parameter: app/console cache:clear --env=prod --no-debug

你错过了env参数:app / console cache:clear --env = prod --no-debug

#2


1  

i believe you can try app/console cache:clear --no-warmup

我相信你可以试试app / console cache:clear --no-warmup

#3


0  

To clear the cache and instantly access the data my fix is

要清除缓存并立即访问我的修复数据

sudo app/console cache:clear --env=prod --no-warmup --no-debug

using this command turns off debug, and doesn't have a warmup time before the data is accessible again

使用此命令将关闭调试,并且在再次访问数据之前没有预热时间