Java Code Examples for org.springframework.data.redis.core.RedisTemplate#setEnableTransactionSupport()
The following examples show how to use
org.springframework.data.redis.core.RedisTemplate#setEnableTransactionSupport() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisConfig.java From ext-opensource-netty with Mozilla Public License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Bean(name="redisTemplateHash") @Scope("prototype") public RedisTemplate redisTemplateHash(){ RedisSerializer valueSerializer = new GsonRedisSerializer(Object.class); RedisSerializer keySerializer = new StringRedisSerializer(); RedisTemplate redisTemplate = new RedisTemplate(); redisTemplate.setConnectionFactory(jedisConnectionFactory()); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(keySerializer); redisTemplate.setHashValueSerializer(valueSerializer); redisTemplate.afterPropertiesSet(); redisTemplate.setEnableTransactionSupport(true); return redisTemplate; }
Example 2
Source File: RedisConfig.java From jeesupport with MIT License | 6 votes |
@Bean @ConditionalOnMissingBean( name = "redisTemplate" ) @Primary public < T > RedisTemplate< String, T > redisTemplate( RedisConnectionFactory _rcf ){ RedisTemplate< String, T > template = new RedisTemplate<>(); //使用fastjson序列化 // value值的序列化采用fastJsonRedisSerializer template.setValueSerializer( new FastJsonRedisSerializer<T>() ); template.setHashValueSerializer( new FastJsonRedisSerializer<T>() ); // key的序列化采用StringRedisSerializer template.setKeySerializer( new FastJsonRedisSerializer<T>() ); template.setHashKeySerializer( new FastJsonRedisSerializer<T>() ); template.setConnectionFactory( _rcf ); // 开启事务 template.setEnableTransactionSupport( true ); template.afterPropertiesSet(); return template; }
Example 3
Source File: EmailRedisTemplateConfiguration.java From spring-boot-email-tools with Apache License 2.0 | 6 votes |
@Bean @Qualifier("valueTemplate") public RedisTemplate<String, EmailSchedulingData> createValueTemplate() throws IOException { RedisTemplate<String, EmailSchedulingData> template = new RedisTemplate<>(); RedisSerializer<String> stringSerializer = new StringRedisSerializer(); JdkSerializationRedisSerializer jdkSerializationRedisSerializer = new JdkSerializationRedisSerializer(); template.setKeySerializer(stringSerializer); template.setValueSerializer(jdkSerializationRedisSerializer); template.setHashKeySerializer(stringSerializer); template.setHashValueSerializer(stringSerializer); template.setConnectionFactory(redisConnectionFactory); template.setEnableTransactionSupport(true); template.afterPropertiesSet(); return template; }
Example 4
Source File: RedisConfig.java From springBoot-study with Apache License 2.0 | 5 votes |
/** * 设置数据存入 redis 的序列化方式,并开启事务 * @param redisTemplate * @param factory */ private void initDomainRedisTemplate(RedisTemplate<String, Object> redisTemplate, RedisConnectionFactory factory) { //如果不配置Serializer,那么存储的时候缺省使用String,如果用User类型存储,那么会提示错误User can't cast to String! redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); // 开启事务 redisTemplate.setEnableTransactionSupport(true); redisTemplate.setConnectionFactory(factory); }
Example 5
Source File: BaseRedisTest.java From spring-boot-email-tools with Apache License 2.0 | 5 votes |
@Bean("valueTemplate") public RedisTemplate<String, EmailSchedulingData> createValueTemplate() throws IOException { RedisTemplate<String, EmailSchedulingData> template = new RedisTemplate<>(); RedisSerializer<String> stringSerializer = new StringRedisSerializer(); JdkSerializationRedisSerializer jdkSerializationRedisSerializer = new JdkSerializationRedisSerializer(); template.setKeySerializer(stringSerializer); template.setValueSerializer(jdkSerializationRedisSerializer); template.setHashKeySerializer(stringSerializer); template.setHashValueSerializer(stringSerializer); template.setConnectionFactory(connectionFactory); template.setEnableTransactionSupport(true); template.afterPropertiesSet(); return template; }
Example 6
Source File: RedisConfig.java From spring-microservice-boilerplate with MIT License | 5 votes |
@Bean(name = "limitRedisTemplate") public RedisTemplate<String, RequestCount> limitRedisTemplate(RedisConnectionFactory cf) { RedisTemplate<String, RequestCount> redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer(RequestCount.class)); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer(RequestCount.class)); redisTemplate.setEnableTransactionSupport(true); redisTemplate.setConnectionFactory(cf); return redisTemplate; }