spring-projects/spring-data-redis

Support custom `NullValueSerializer` in `GenericJackson2JsonRedisSerializer`

ekeric13 opened this issue · 1 comments

If one wants a custom NullValueSerializer you can define your own registerNullValueSerializer, you cannot define your own NullValueSerializer

but because registerNullValueSerializer is static, you have to also overwrite other methods like the base constructors.

so how can one easily define their own nullValueSerializer?
the use case in particular i am using it as redis is used as the backend for @cachable and i want to cache the fact that i have a null value for some keys. the default null that the redis serializer uses is jsonGenerator.writeStringField(classIdentifier, NullValue.class.getName());, which produces a weird byte array that when i try to deserialize it (access the cache later) it gives me an error.

And then semi-related, if i overwrite the deserialize method to return null if i see the special null identifier, @cacheable considers it a cache miss. but i actually really do want to return the value null from my cache!!

May I handle this issue? I'll create PR on this weekend :)