Spring Data Redis Operation key type

36 views Asked by At

Good evening! I want to create ReactiveRedisOperations with keys of type Long, but i cannot fing Long deserializer for that.

@Configuration
class RedisConfiguration {

    @Bean
    fun reactiveRedisOperations(factory: ReactiveRedisConnectionFactory): ReactiveRedisOperations<Long, SessionDAO> {
        val keyDeserializer: //Here should be some like LongRedisDeserializer, but i've found only String and Json
        val valueSerializer = Jackson2JsonRedisSerializer(jacksonObjectMapper(),SessionDAO::class.java)
        val context = RedisSerializationContext.newSerializationContext<Long, SessionDAO>(StringRedisSerializer())
            .key(keyDeserializer)
            .value(valueSerializer)
            .hashKey(keyDeserializer)
            .hashValue(valueSerializer)
            .build()

        return ReactiveRedisTemplate(factory, context)
    }

}

Can you please tell me how to do it?

0

There are 0 answers