colinmollenhour / Cm_Cache_Backend_Redis

A Zend_Cache backend for Redis with full support for tags (works great with Magento)
Other
390 stars 142 forks source link

diffiniate empty cache entry and non-existing cache entry #176

Open onlinebizsoft opened 1 year ago

onlinebizsoft commented 1 year ago

image

https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/blob/3fc3e9149097f67cded1c425088e37d7fa8083ed/Cm/Cache/Backend/Redis.php#L513

Look like if we save a cache entry with empty content then when we load, it is treated as non-existing cache entry so this makes some wrong logic in application usages. It would be considered as a bug or we can't do anything in this case? @colinmollenhour

colinmollenhour commented 1 year ago

So if you save an empty string you get false? Seems that could be an issue with save then rather than load?

onlinebizsoft commented 1 year ago

@colinmollenhour no, saving return true as expected. It should be an issue with load

colinmollenhour commented 1 year ago

I did not state my question well.. I meant, if you save an empty string and then load that key, you get false?

Please provide steps to produce, expected result and actual result for clarity.

onlinebizsoft commented 1 year ago

Yes, exactly, this is used and tested in a context of Magento 2 project.

colinmollenhour commented 1 year ago

My system is messed up at the moment.. as a workaround you could use the test() method to check for existence of a key regardless of if it was empty or not.

onlinebizsoft commented 1 year ago

Thanks, currently I can avoid using empty block or empty cache on the project. I just wanted to report the bug because in some cases, it can cause performance or other issues.