Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2222

Spring redis configuration in cluster mode

$
0
0

I have this redis configuration class which sets the transaction support to True. The redis is in a clustered mode. When the application calls this haskey method, the application returns the following error:

org.springframework.dao.InvalidDataAccessApiUsageException: MULTI is currently not supported in cluster mode.

public boolean hasKey(String key) {        return redisTemplate.hasKey(key);    }
@Configuration@RefreshScopepublic class RedisConfiguration {    @Bean    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {        final RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();        redisTemplate.setKeySerializer(new StringRedisSerializer());        redisTemplate.setHashKeySerializer(new GenericToStringSerializer<Object>(Object.class));        redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());        redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());        redisTemplate.setConnectionFactory(connectionFactory);        redisTemplate.setEnableTransactionSupport(true);        return redisTemplate;    }}

If I put setEnableTransactionSupport to false, the haskey method does not throw error anymore. May I know if transaction support is available for clustered redis?


Viewing all articles
Browse latest Browse all 2222

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>