List of usage examples for org.springframework.data.redis.core RedisTemplate setConnectionFactory
public void setConnectionFactory(RedisConnectionFactory connectionFactory)
From source file:org.springframework.integration.redis.outbound.RedisCollectionPopulatingMessageHandler.java
/** * Will construct this instance using the provided {@link RedisConnectionFactory} and {@link #keyExpression} * It will create an instance of {@link RedisTemplate} initializing it with a * {@link StringRedisSerializer} for the keySerializer and a {@link JdkSerializationRedisSerializer} * for each of valueSerializer, hasKeySerializer, and hashValueSerializer. * * If {@link #keyExpression} is null, the default expression 'headers.{@link RedisHeaders#KEY}' * will be used.// ww w .j ava 2 s .com * * @param connectionFactory * @param keyExpression */ public RedisCollectionPopulatingMessageHandler(RedisConnectionFactory connectionFactory, Expression keyExpression) { Assert.notNull(connectionFactory, "'connectionFactory' must not be null"); RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>(); redisTemplate.setConnectionFactory(connectionFactory); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); redisTemplate.setHashKeySerializer(new JdkSerializationRedisSerializer()); redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer()); this.redisTemplate = redisTemplate; if (keyExpression != null) { this.keyExpression = keyExpression; } }
From source file:org.springframework.integration.redis.util.RedisLockRegistryTests.java
private RedisTemplate<String, ?> createTemplate() { RedisTemplate<String, ?> template = new RedisTemplate<>(); template.setConnectionFactory(this.getConnectionFactoryForTest()); template.setKeySerializer(new StringRedisSerializer()); template.afterPropertiesSet();/* www. ja v a 2 s .c o m*/ return template; }
From source file:org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration.java
private RedisTemplate<Object, Object> createRedisTemplate() { RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); if (this.defaultRedisSerializer != null) { redisTemplate.setDefaultSerializer(this.defaultRedisSerializer); }//from www . java2 s .com redisTemplate.setConnectionFactory(this.redisConnectionFactory); redisTemplate.setBeanClassLoader(this.classLoader); redisTemplate.afterPropertiesSet(); return redisTemplate; }
From source file:org.springframework.session.data.redis.RedisOperationsSessionRepository.java
private static RedisTemplate<Object, Object> createDefaultTemplate(RedisConnectionFactory connectionFactory) { Assert.notNull(connectionFactory, "connectionFactory cannot be null"); RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>(); template.setKeySerializer(new StringRedisSerializer()); template.setHashKeySerializer(new StringRedisSerializer()); template.setConnectionFactory(connectionFactory); template.afterPropertiesSet();/*from ww w .ja v a2 s.c o m*/ return template; }