清除 Symfony 中的缓存:`cache:clear` 或 `rm -rf`? [英] Clear cache in Symfony: `cache:clear` or `rm -rf`?
问题描述
./bin/console cache:clear --env=prod
和 rm -rf var/cache/prod/*
有什么区别?控制台命令很慢.Bash 命令很快.那么,...为什么使用 cache:clear
而不是 rm
?
Which is the difference between ./bin/console cache:clear --env=prod
and rm -rf var/cache/prod/*
? Console command is very slow. Bash command is fast. So, ... why use cache:clear
instead of rm
?
推荐答案
cache:clear
擦除先前创建的缓存项,但也,它会进行缓存预热.在此基础上,您的应用程序应该加载得非常快,因为缓存已经预先填充.
cache:clear
wipes previously created cache items, but also, it does a cache warm-up. Upon this, you application should load very fast due to the fact that cache was already pre-populated.
另一方面,rm -rf
只完成工作的一部分.在此之后第一次尝试加载应用程序时,您应该会注意到性能影响.
On the other hand, rm -rf
does only one part of the job. You should notice performance impact when you try to load you app the first time after this.
我还想指出另一件事:权限.例如,如果您以 root
身份登录,并且没有通过 setfacl
(或任何其他方法)设置访问权限,则 cache:clear
很可能会创建 root
拥有的缓存项.这可能是一个问题.
I would also like to point out another thing: permissions. If you are logged in as root
for example, and you did not set access rights via setfacl
(or any other method), cache:clear
will most probably create your cache items owned by root
. This could be an issue, down the line.
希望这会有所帮助...
Hope this helps a bit...
这篇关于清除 Symfony 中的缓存:`cache:clear` 或 `rm -rf`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!