Весенние данные redis timetolive не удалось установить - PullRequest
0 голосов
/ 13 мая 2019

У меня есть приложение для хранения некоторых данных, чтобы их можно было восстановить и восстановить. Когда я использую аннотацию timetolive поле и когда я устанавливаю значение для него, redis-cli не может показывать тайм-аут. Мой Конфигурационный класс;

@ComponentScan("com.ykb.frd.fraudbase.entity.redis")
@EnableRedisRepositories(basePackages = "com.ykb.frd.fraudbase.repository.redis")
@Configuration
@PropertySource({"classpath:application.properties"})
public class RedisConfiguration {

    @Autowired
    Environment environment;

    @Bean
    public RedisTemplate<String, Object> redisTemplate() {
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        template.setConnectionFactory(jedisConnectionFactory());
        return template;
    }

    @Bean
    JedisConnectionFactory jedisConnectionFactory() {
        String host = environment.getProperty("redis.host");
        String portStr = environment.getProperty("redis.port");
        int port=6379;
        if(portStr!=null) {
            port=Integer.valueOf(portStr);
        }
        String passwordStr = environment.getProperty("redis.password");
        RedisPassword password = RedisPassword.of(passwordStr);
        RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(host,port);
        redisStandaloneConfiguration.setPassword(password);
        return new JedisConnectionFactory(redisStandaloneConfiguration);
    }

} 

Моя сущность;

@Getter
@Setter
@RedisHash("userSearch")
public class UserSearchEntity implements Serializable {
    @Id
    @Indexed
    private Integer cifNo;
    private String firstName;
    private String lastName;
    private String tckn;

    @TimeToLive
    private Long expiration;
}

Repository;

@Repository
public interface UserSearchRepository extends CrudRepository<UserSearchEntity,String> {
    UserSearchEntity findByCifNo(Integer cifNo);
}

Как я могу решить эту проблему?

...