3

For security reasons I want to rename the command set and flushDb using the redis configuration. But I'm using the redisTemplate which only allows me to use the methods set and flushDb and not a renamed command

Below my used configuration:

@Bean
public RedisTemplate<String, Person> redisTemplate() {
    RedisTemplate<String, Person> template = new RedisTemplate<>()
    template.setConnectionFactory(redisConnectionFactory)
    template.setKeySerializer(new StringRedisSerializer())
    template.setValueSerializer(new JacksonJsonRedisSerializer<>(Person.class))
    template.setHashKeySerializer(new StringRedisSerializer())
    template.setHashValueSerializer(new JacksonJsonRedisSerializer<>(Person.class))
    return template
}

The normal way to set my object in Redis is like:

public void savePerson(Person person) {
    String key = "personId:${person.id}"
    redisTemplate.opsForValue().set(key, person)
}

Any ideas?

Matti van Aert
  • 111
  • 1
  • 7
  • That's not possible with Spring Data Redis but it sounds like a driver issue. You can watch [Issue #625](https://github.com/xetorthio/jedis/issues/625) for Jedis. For lettuce, there's no such ticket yet, but it might be worth investigating the issue. It would require providing a mapping between the renamed command name and the command name you'd like to map at driver config level. – mp911de Jun 19 '16 at 16:04

0 Answers0