Ошибка весенней загрузки StringRedisTemplate (истекло время ожидания команды Redis) при использовании салата - PullRequest
0 голосов
/ 11 апреля 2019

Когда я использовал spring-boot + jedis + pipe, добавление 10000 данных было нормальным. Но когда я использовал spring-boot + Lettuce + pipeline add 10000, я столкнулся с ошибкой. CommandTimeout установлен 5 секунд.

Redis Config:

final LettuceClientConfiguration lettuceClientConfiguration = builder.commandTimeout(Duration.ofMillis(timeout)).poolConfig(poolConfig)
            .build();
final RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
config.setDatabase(database);
config.setHostName(host);
config.setPort(port);
return new LettuceConnectionFactory(config, lettuceClientConfiguration);

Пружинный трубопровод:

stringRedisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(final RedisConnection connection)
                throws DataAccessException {
            for (final Map.Entry<String, String> entry : datas.entrySet()){
                connection.set(key, value);
            }
            return true;
        }
    }, false, true);

Ошибка:

org.springframework.dao.QueryTimeoutException: Redis command timed out; nested exception is io.lettuce.core.RedisCommandTimeoutException: io.lettuce.core.RedisCommandTimeoutException: Command timed out after 5 second(s)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:70)
at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:268)
at org.springframework.data.redis.connection.lettuce.LettuceKeyCommands.convertLettuceAccessException(LettuceKeyCommands.java:817)
at org.springframework.data.redis.connection.lettuce.LettuceKeyCommands.keys(LettuceKeyCommands.java:229)
at org.springframework.data.redis.connection.DefaultedRedisConnection.keys(DefaultedRedisConnection.java:97)
at org.springframework.data.redis.connection.DefaultStringRedisConnection.keys(DefaultStringRedisConnection.java:630)
at org.springframework.data.redis.core.RedisTemplate.lambda$keys$13(RedisTemplate.java:883)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:224)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
at org.springframework.data.redis.core.RedisTemplate.keys(RedisTemplate.java:883)
...