List of usage examples for org.springframework.data.redis.core RedisTemplate setHashKeySerializer
public void setHashKeySerializer(RedisSerializer<?> hashKeySerializer)
From source file:cn.org.once.cstack.config.CacheConfiguration.java
@Bean public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory cf) { RedisTemplate<String, String> redisTemplate = new RedisTemplate<String, String>(); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); redisTemplate.setConnectionFactory(cf); return redisTemplate; }
From source file:com.hillert.botanic.config.HttpSessionConfig.java
@Bean public RedisTemplate<String, ExpiringSession> redisTemplate(RedisConnectionFactory connectionFactory) { RedisTemplate<String, ExpiringSession> template = new RedisTemplate<String, ExpiringSession>(); template.setKeySerializer(new StringRedisSerializer()); template.setHashKeySerializer(new StringRedisSerializer()); template.setConnectionFactory(connectionFactory); return template; }
From source file:io.gravitee.repository.redis.management.ManagementRepositoryConfiguration.java
@Bean(name = "managementRedisTemplate") public RedisTemplate redisTemplate( org.springframework.data.redis.connection.RedisConnectionFactory redisConnectionFactory) { RedisTemplate redisTemplate = new RedisTemplate(); redisTemplate.setConnectionFactory(redisConnectionFactory); redisTemplate.setKeySerializer(redisTemplate.getStringSerializer()); redisTemplate.setHashKeySerializer(redisTemplate.getStringSerializer()); redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class)); redisTemplate.setDefaultSerializer(new Jackson2JsonRedisSerializer<>(Object.class)); return redisTemplate; }
From source file:com.enitalk.configs.RedisConfig.java
@Bean @Primary/*from ww w . j a v a 2 s . c om*/ public RedisTemplate<String, String> redisTemplate() { RedisTemplate<String, String> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(jedisConnectionFactory()); redisTemplate.setKeySerializer(redisSerializer()); redisTemplate.setHashKeySerializer(redisSerializer()); redisTemplate.setHashValueSerializer(redisSerializer()); return redisTemplate; }
From source file:stormy.pythian.service.spring.ServiceConfiguration.java
@Bean public RedisTemplate<String, PythianToplogyConfiguration> redisTopologyTemplate() { RedisTemplate<String, PythianToplogyConfiguration> template = new RedisTemplate<>(); template.setConnectionFactory(redisConnectionFactory()); template.setKeySerializer(new StringRedisSerializer()); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new JacksonJsonRedisSerializer<>(PythianToplogyConfiguration.class)); return template; }
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./*from w w w. j a v a 2 s. co m*/ * * @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.outbound.RedisStoreWritingMessageHandler.java
@Override protected void onInit() throws Exception { this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory()); Assert.state(!this.mapKeyExpressionExplicitlySet || (this.collectionType == CollectionType.MAP || this.collectionType == CollectionType.PROPERTIES), "'mapKeyExpression' can only be set for CollectionType.MAP or CollectionType.PROPERTIES"); if (!this.redisTemplateExplicitlySet) { if (!this.extractPayloadElements) { RedisTemplate<String, Object> template = new RedisTemplate<String, Object>(); StringRedisSerializer serializer = new StringRedisSerializer(); template.setKeySerializer(serializer); template.setHashKeySerializer(serializer); this.redisTemplate = template; }/*from w ww . j a v a2s .c o m*/ this.redisTemplate.setConnectionFactory(this.connectionFactory); this.redisTemplate.afterPropertiesSet(); } this.initialized = true; }
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); }/* w w w . j a v a 2 s .co m*/ 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();/*w w w.ja v a 2 s . co m*/ return template; }