Caching null-values

java

Solution

I doubt there is an official document for this case as the answer strongly depends on your usage. For instance imagine you have a web query taking 200 ms to be processed that returns null and that is a valid value. Of course you would cache this to avoid these extra 200 ms everytime you do the query.

I am personally with you on the case. Rules saying never do... are rarely without an exception.

Problem

I'm having an argument with my chief architect about caching null-values. His opinion is, that null-values by definition aren't cached. My problem now is, that there is always a cache-miss and a piece of code is always entered without any need, since the null value is totally fine in my case. My question: Is there an official definition on this case?

Original source