Cm_Cache_Backend_Redis icon indicating copy to clipboard operation
Cm_Cache_Backend_Redis copied to clipboard

diffiniate empty cache entry and non-existing cache entry

Open onlinebizsoft opened this issue 2 years ago • 6 comments

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

onlinebizsoft avatar Jun 16 '23 10:06 onlinebizsoft

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

colinmollenhour avatar Jun 16 '23 18:06 colinmollenhour

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

onlinebizsoft avatar Jun 17 '23 00:06 onlinebizsoft

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.

colinmollenhour avatar Jun 19 '23 16:06 colinmollenhour

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

onlinebizsoft avatar Jun 20 '23 02:06 onlinebizsoft

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.

colinmollenhour avatar Jun 21 '23 00:06 colinmollenhour

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.

onlinebizsoft avatar Jun 21 '23 01:06 onlinebizsoft