What is the preferred cache directory using Zend_Cache?

1.4k views Asked by At

On my dev system (Ubuntu 11.10) I have no problems writing my cache files to /tmp but I'm concerned about what will happen to my application when deployed. I currently have shared hosting so I'm guessing I won't have access to that directory? My app directory looks like this:

MyApp
- application
   - cache
   - configs
   - controllers
   - forms
   - layouts
   - logs
   - models
   - views
- docs
- library
- public
- tests

I created a custom folder in my applications directory called cache (as you can see above) and then used the following to configure it:

$frontendOptions = array('lifeTime' => (strtotime('tomorrow') - time()));
$backendOptions = array('cacheDir' => '../application/cache/');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);

I used the path ../application/cache/ because everything is referenced in Zend_Framework from the index.php (i.e. front controller) located in the public folder.

When I do this, it still writes my cache to the /tmp folder. What am I missing?

1

There are 1 answers

1
BartekR On BEST ANSWER

I think you have a typo:

$backendOptions = array('cache_dir' => '../application/cache/');

Not cacheDir :

http://framework.zend.com/manual/en/zend.cache.backends.html