当前位置: 首页>>代码示例>>Java>>正文


Java RedisTemplate.afterPropertiesSet方法代码示例

本文整理汇总了Java中org.springframework.data.redis.core.RedisTemplate.afterPropertiesSet方法的典型用法代码示例。如果您正苦于以下问题:Java RedisTemplate.afterPropertiesSet方法的具体用法?Java RedisTemplate.afterPropertiesSet怎么用?Java RedisTemplate.afterPropertiesSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.redis.core.RedisTemplate的用法示例。


在下文中一共展示了RedisTemplate.afterPropertiesSet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRedisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
public static RedisTemplate buildRedisTemplate(byte[] redisProperties){
    JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(
            RedisConfUtils.getClusterConfiguration(
                    (RedisProperties) Serializer.INSTANCE.deserialize(redisProperties)));
    RedisTemplate<String, Long> redisTemplate = new RedisTemplate<>();
    redisTemplate.setConnectionFactory(jedisConnectionFactory);
    jedisConnectionFactory.afterPropertiesSet();

    GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
    StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
    redisTemplate.setKeySerializer(stringRedisSerializer);
    redisTemplate.setValueSerializer(genericJackson2JsonRedisSerializer);
    redisTemplate.setHashKeySerializer(stringRedisSerializer);
    redisTemplate.setHashValueSerializer(genericJackson2JsonRedisSerializer);
    redisTemplate.afterPropertiesSet();
    return redisTemplate;
}
 
开发者ID:Paleozoic,项目名称:storm_spring_boot_demo,代码行数:18,代码来源:RedisConfUtils.java

示例2: redisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
    RedisTemplate<Object, Object> template = new RedisTemplate<>();
    template.setConnectionFactory(connectionFactory);

    //使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
    Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(Object.class);

    ObjectMapper mapper = new ObjectMapper();
    mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    serializer.setObjectMapper(mapper);

    template.setValueSerializer(serializer);
    //使用StringRedisSerializer来序列化和反序列化redis的key值
    template.setKeySerializer(new StringRedisSerializer());
    template.afterPropertiesSet();
    return template;
}
 
开发者ID:fanqinghui,项目名称:action,代码行数:20,代码来源:RedisUtil.java

示例3: redisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
@Bean(name = "redisTemplate")
public RedisTemplate<String,?> redisTemplate(@Qualifier("mafConnectionFactory") RedisConnectionFactory factory) {
    RedisTemplate<String,?> template = new RedisTemplate<>();
    template.setConnectionFactory(factory);
    template.setKeySerializer(new StringRedisSerializer());
    template.afterPropertiesSet();
    return template;
}
 
开发者ID:slking1987,项目名称:mafia,代码行数:9,代码来源:RedisConfig.java

示例4: redisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
@Bean
public <K, V> RedisTemplate<K, V> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
    RedisTemplate<K, V> template = new RedisTemplate<>();
    template.setConnectionFactory(redisConnectionFactory);
    template.setKeySerializer(new StringRedisSerializer());
    template.setHashKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
    template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
    template.setEnableTransactionSupport(true);
    template.afterPropertiesSet();
    return template;
}
 
开发者ID:tong12580,项目名称:OutsourcedProject,代码行数:13,代码来源:RedisConfig.java

示例5: byteRedisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
@Bean
public RedisTemplate byteRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
    RedisTemplate redisTemplate = new RedisTemplate();
    redisTemplate.setConnectionFactory(redisConnectionFactory);
    redisTemplate.setEnableDefaultSerializer(true);
    //redisTemplate.setDefaultSerializer(new StringRedisSerializer());
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    //redisTemplate.setValueSerializer(new StringRedisSerializer());
    //redisTemplate.setEnableTransactionSupport(true);
    redisTemplate.afterPropertiesSet();
    return redisTemplate;
}
 
开发者ID:lupindong,项目名称:xq_seckill_microservice,代码行数:13,代码来源:CachingConfig.java

示例6: stringRedisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
@Bean
public RedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
    RedisTemplate redisTemplate = new RedisTemplate();
    redisTemplate.setConnectionFactory(redisConnectionFactory);
    redisTemplate.setEnableDefaultSerializer(true);
    redisTemplate.setDefaultSerializer(new StringRedisSerializer());
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new StringRedisSerializer());
    //redisTemplate.setEnableTransactionSupport(true);
    redisTemplate.afterPropertiesSet();
    return redisTemplate;
}
 
开发者ID:lupindong,项目名称:xq_seckill_microservice,代码行数:13,代码来源:CachingConfig.java

示例7: redisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) {
    RedisTemplate template = new RedisTemplate<>();
    template.setConnectionFactory(connectionFactory);
    //使用StringRedisSerializer来序列化和反序列化redis的key值, value值默认会使用JdkSerializationRedisSerializer
    template.setKeySerializer(new StringRedisSerializer());
    template.afterPropertiesSet();
    return template;
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:10,代码来源:MessageConverterConfig.java

示例8: redisTemplate

import org.springframework.data.redis.core.RedisTemplate; //导入方法依赖的package包/类
@Bean
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory) {
	RedisTemplate template = new RedisTemplate();

	template.setConnectionFactory(factory);

	RedisSerializer keySerializer = new StringRedisSerializer();

	// 设置key序列化类,否则key前面会多了一些乱码
	template.setKeySerializer(keySerializer);
	template.setHashKeySerializer(keySerializer);

	// FIXME 有些版本有bug,没有序列化的只能序列化,但无法反序列化
	GenericJackson2JsonRedisSerializer jsonSerializer = new GenericJackson2JsonRedisSerializer();

	// 设置内容序列化类
	template.setValueSerializer(jsonSerializer);

	template.afterPropertiesSet();

	return template;
}
 
开发者ID:xwjie,项目名称:ElementVueSpringbootCodeTemplate,代码行数:23,代码来源:RedisConfig.java


注:本文中的org.springframework.data.redis.core.RedisTemplate.afterPropertiesSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。