简体   繁体   English

Symfony2:具有多个环境的相同代码库导致大量缓存文件

[英]Symfony2: Same codebase with multiple environments leads to tons of cache files

I have a running Symfony2 application which uses the same codebase, but different environment names to map to different DBs. 我有一个正在运行的Symfony2应用程序,该应用程序使用相同的代码库,但使用不同的环境名称映射到不同的数据库。

For example: 例如:

foo .example.com --> uses env foo bar .example.com --> uses env bar foo .example.com->使用env foo bar .example.com->使用env bar

Of course, I have now different cache and logs for each user. 当然,我现在为每个用户拥有不同的缓存日志

The cache thing is what bothers me, it's creating tons of files (1 cache dir per subdomain), and it ended up filling my inodes to the limit. 缓存问题困扰着我,它正在创建大量文件(每个子域1个缓存目录),最终使我的inode达到了极限。

Is there a way to share the cache between environments, or maybe not using environments to access different dbs? 有没有一种方法可以在环境之间共享缓存,或者是否不使用环境来访问不同的数据库?

Each subdomain should have its own DB , that's the only requirements. 每个子域都应该有自己的DB ,这是唯一的要求。 Right now we are using different environments to accomplish that. 现在,我们正在使用不同的环境来实现这一目标。

Suggestions? 建议?

The problem is not that an environment has a lot of cache files. 问题不是环境中有很多缓存文件。 The problem is that the idea of environment is exploited the wrong way. 问题是环境观念被错误地利用。

A better solution for your situation is to define your db name based on the subdomain: foo.example.com will have the db foo_db, etc. A simple convention like that. 针对您的情况的更好解决方案是根据子域定义数据库名称:foo.example.com将具有数据库foo_db等。类似这样的简单约定。

This answer may help you 这个答案可能对您有帮助

https://stackoverflow.com/a/8314039/410761 https://stackoverflow.com/a/8314039/410761

You override the base methods to define whatever cache / logs folder you prefer. 您可以覆盖基本方法来定义所需的任何缓存/日志文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM