micronaut-cache icon indicating copy to clipboard operation
micronaut-cache copied to clipboard

Null values are not cached

Open morki opened this issue 4 years ago • 13 comments

Is it intended that null value is not cached? I think it has to be configurable, because null is valid value for me, or am I missing something?

Example:

@Cacheable("test")
fun getCompanyForUser(id: Long): String? {
   // implementation
}

Not every user has to have company, but when the method returns null, it's not cached, but called every time. I didn't even find this behaviour documented.

I am using io.micronaut.cache:micronaut-cache-caffeine:2.0.0.M2.

morki avatar Jun 07 '20 14:06 morki