ZF-10500: Empty array isn't being stored in cache
Description
Empty arrays cannot be stored in cache. Though, an empty array may result from a very expensive SQL. So no matter the value of the variable that needs to be cached, it just should be cached.
Comments
Posted by Marc Bennewitz (private) (mabe) on 2010-09-29T10:36:20.000+0000
Please tell us which Backend and Frontend you are using and your configuration options
Posted by Mathieu Decaffmeyer (mathi) on 2010-09-30T04:38:51.000+0000
Hi Marc, I'm using Core File, below is my configuration :
$frontendOptions = array('lifetime' => NULL, 'automatic_serialization' => true); $backendOptions = array('cache_dir' => './tmp/', 'hashed_directory_level' => 2); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Posted by Marc Bennewitz (private) (mabe) on 2010-09-30T14:11:51.000+0000
I can't reproduce it.
The following is true on my machine with your cache object:
Can you please create a small test script and tell me your used version of ZF.
Posted by Mathieu Decaffmeyer (mathi) on 2010-09-30T15:48:45.000+0000
Marc, you are right. I took the code from the doc :
if(!$result = $cache->load('myresult')) { ... }
The empty array will of course execute the if block ... I hate loose typing :-)
Posted by Mathieu Decaffmeyer (mathi) on 2010-09-30T15:56:05.000+0000
What about changing the doc a little bit ?
$result = $cache->load('myresult'); if($result === false) { ... }
The cache could return "0", "", array(), etc. Only strictly false should be checked because only false will be return when there is no cache hit.
Posted by Marc Bennewitz (private) (mabe) on 2010-10-01T08:57:38.000+0000
changed type to doc
Posted by Marc Bennewitz (private) (mabe) on 2010-10-01T09:08:17.000+0000
changed in r23013