3

I'm using Zend Framework and Zend_Cache with the File backend.

According to the ZF manual the recommended place to store the cache files would be under /data/cache but I'm thinking it would make more sense to store them under /temp/cache. Why is /data/cache preferred?

Here is a link to the part of ZF manual I mentioned: http://framework.zend.com/manual/en/project-structure.project.html

Liyali
  • 5,643
  • 2
  • 26
  • 40
Lars Nyström
  • 5,786
  • 3
  • 32
  • 33

2 Answers2

4

I guess you're talking about these recommendations: Recommended Project Directory Structure.

The interesting parts are:

data/: This directory provides a place to store application data that is volatile and possibly temporary. The disturbance of data in this directory might cause the application to fail. Also, the information in this directory may or may not be committed to a subversion repository. Examples of things in this directory are session files, cache files, sqlite databases, logs and indexes.


temp/: The temp/ folder is set aside for transient application data. This information would not typically be committed to the applications svn repository. If data under the temp/ directory were deleted, the application should be able to continue running with a possible decrease in performance until data is once again restored or recached.

Now, you can understand that Zend doesn't recommend to store your Zend_Cache data into data/cache/ only, but it could also be stored under the temp/ directory. The real question is: should I commit these data cache files and are they necessary for the application to run correctly? Once you answered these questions, you know where you should put your cache files. In my opinion, in most cases cached data should be stored under the temp/ directory.

Finally, remember that this is only a recommendation, you are always free to do the way you want.

Liyali
  • 5,643
  • 2
  • 26
  • 40
  • +1 for asking the right questions. But isn't an application that crashes when the cache is deleted misuing the cache? I'd say a cache is temporary by nature and can't ever be relied upon. Am i missing something? – Lars Nyström Apr 15 '12 at 12:51
  • You are right and I agree with you. This is why I said in most cases the _temp/_ directory will be enough. Note that the documentation says "**might cause the application to fail**", so it will not necessary cause the application to fail. – Liyali Apr 15 '12 at 13:02
  • I'm still confused as to why Zend even suggests that the cache can be stored under data/ if we can all agree on a caches temporary nature. But you solved my problem at hand, thank you! – Lars Nyström Apr 15 '12 at 13:14
2

I can't find the part of the Zend_Cache manual that recommends using data/cache as the cache directory, maybe you could link to it. I did find some examples that use ./temp/.

Either way, Zend Cache doesn't care where you decide to store the cache files, it is up to you. You just need to make sure that the directory is readable and writable by PHP.

vascowhite
  • 18,120
  • 9
  • 61
  • 77