Okizb
Okizb

Reputation: 99

Zend_Cache default cache_dir in application.ini

On my server I have multiple virtual hosts, I run on them several applications based on ZF 1.12. When caching data (with Zend_Cache_Backend_File), each project saves files in /tmp.

The problem is there are some name and access rights problems. Running project2 I get this error:

Warning: fopen(/tmp/zend_cache---internal-metadatas---Zend_LocaleC_de_DE_currencynumber_)

and that is because the file was made by project1 running on separate virtual host.

So I would like to define separate folder for each project's cached data, something like this:

/tmp/porject1

/tmp/project2

The best way IMO would be to do this using application.ini - so I tried this:

resources.cachemanager.database.backend.name = File
resources.cachemanager.database.backend.customBackendNaming = false
resources.cachemanager.database.backend.options.cache_dir = "/tmp/project1"

But it isn't working - the data is still saved in /tmp - what am I doing wrong?

Upvotes: 0

Views: 1548

Answers (1)

Oswaldo Acauan
Oswaldo Acauan

Reputation: 2740

When looking at the Zend/Cache/Backend.php code, there are some alternatives to allow correct guessing of the cache_dir:

  • Setting evironment variables like TMPDIR, TEMP or TMP
  • set "upload_tmp_dir" in php.ini
  • allow access to "/tmp" or "\temp"

Then $_SERVER['TEMP'] = realpath('/tmp/project1'); will solve your problem.

Remember to change the permission to 777 in the cache folder

Upvotes: 1

Related Questions