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


Java GenericJackson2JsonRedisSerializer类代码示例

本文整理汇总了Java中org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer的典型用法代码示例。如果您正苦于以下问题:Java GenericJackson2JsonRedisSerializer类的具体用法?Java GenericJackson2JsonRedisSerializer怎么用?Java GenericJackson2JsonRedisSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GenericJackson2JsonRedisSerializer类属于org.springframework.data.redis.serializer包,在下文中一共展示了GenericJackson2JsonRedisSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRedisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的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.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Bean
@Primary
RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory rcf) {
	AitLogger.debug(logger, "Serializer overriding ");

	RedisTemplate<String, Object> template = new RedisTemplate<>();
	template.setConnectionFactory(rcf);

	GenericJackson2JsonRedisSerializer valSerializer = new GenericJackson2JsonRedisSerializer();

	template.setValueSerializer(valSerializer);
	template.setKeySerializer(new RedisSerializer<Object>() {

		@Override
		public byte[] serialize(Object t) throws SerializationException {
			return (t == null ? null : (":" + t.toString()).getBytes());
		}

		@Override
		public Object deserialize(byte[] bytes) throws SerializationException {
			return (bytes == null ? null : new String(bytes));
		}
	});
	template.setHashValueSerializer(valSerializer);
	return template;
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:27,代码来源:AitCacheConfigBase.java

示例3: savingAndDeletingNodes

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Test
public void savingAndDeletingNodes() throws UnsupportedEncodingException {
	GenericJackson2JsonRedisSerializer serializer = new GenericJackson2JsonRedisSerializer(new ObjectMapper());

	Node node1 = new Node("some id");
	simpleStore.saveNode(new String(serializer.serialize(node1), "UTF-8"));
	assertThat(simpleStore.getAllNodes().size()).isEqualTo(1);

	Node node2 = new Node("another id");
	simpleStore.saveNode(new String(serializer.serialize(node2), "UTF-8"));
	simpleStore.deleteNode("some id");
	assertThat(simpleStore.getAllNodes().iterator().next().getId()).isEqualTo("another id");

	simpleStore.deleteAllNodes();
	assertThat(simpleStore.getAllNodes().size()).isEqualTo(0);

	Node node3 = new Node("again another id");
	simpleStore.saveNode(new String(serializer.serialize(node3), "UTF-8"));
	assertThat(simpleStore.getAllNodesAsObservable()).isNotNull();

	simpleStore.flushDB();
	assertThat(simpleStore.getAllNodes().size()).isEqualTo(0);
}
 
开发者ID:ordina-jworks,项目名称:microservices-dashboard-server,代码行数:24,代码来源:SimpleStoreTest.java

示例4: getStringRedisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Bean
public RedisTemplate getStringRedisTemplate() {
    StringRedisTemplate clusterTemplate = new StringRedisTemplate();
    clusterTemplate.setConnectionFactory(jedisConnectionFactory());
    clusterTemplate.setKeySerializer(new StringRedisSerializer());
    clusterTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
    return clusterTemplate;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:9,代码来源:RedisClusterConfig.java

示例5: redisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的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

示例6: getRedisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Bean("redisTemplate")
public RedisTemplate<?, ?> getRedisTemplate(){
    RedisTemplate<?,?> template = new StringRedisTemplate(jedisConnectionFactory);
    GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
    StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
    template.setKeySerializer(stringRedisSerializer);
    template.setValueSerializer(genericJackson2JsonRedisSerializer);
    template.setHashKeySerializer(stringRedisSerializer);
    template.setHashValueSerializer(genericJackson2JsonRedisSerializer);
    return template;
}
 
开发者ID:Paleozoic,项目名称:storm_spring_boot_demo,代码行数:12,代码来源:RedisConfig.java

示例7: redisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Bean
@Primary
public StringRedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) {
    StringRedisTemplate template = new StringRedisTemplate();
    template.setConnectionFactory(connectionFactory);
    template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
    return template;
}
 
开发者ID:ihaolin,项目名称:diablo,代码行数:9,代码来源:RedisConfig.java

示例8: redisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Bean
RedisTemplate< String, Long > redisTemplate() {
    final RedisTemplate template =  new RedisTemplate();
    template.setConnectionFactory( jedisConnectionFactory() );
    template.setKeySerializer( new StringRedisSerializer() );
    template.setDefaultSerializer(new GenericJackson2JsonRedisSerializer());
    return template;
}
 
开发者ID:shairontoledo,项目名称:cloudstatus,代码行数:9,代码来源:Application.java

示例9: init

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
private void init(RedisConnectionFactory connectionFactory, Jackson2JsonRedisSerializer jsonRedisSerializer) {
    RedisSerializer<String> stringSerializer = new StringRedisSerializer();
    setKeySerializer(new GenericJackson2JsonRedisSerializer());
    setHashKeySerializer(stringSerializer);
    setHashValueSerializer(stringSerializer);
    setValueSerializer(jsonRedisSerializer);
    setConnectionFactory(connectionFactory);
    afterPropertiesSet();
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:10,代码来源:JsonRedisTemplate.java

示例10: redisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Bean
public RedisTemplate<String, Object> redisTemplate(final RedisConnectionFactory factory){
    RedisTemplate<String, Object> virtualNodeTemplate = new RedisTemplate<>();
    virtualNodeTemplate.setConnectionFactory(factory);
    virtualNodeTemplate.setKeySerializer(new StringRedisSerializer());
    virtualNodeTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
    return virtualNodeTemplate;
}
 
开发者ID:ordina-jworks,项目名称:microservices-dashboard-server,代码行数:9,代码来源:RedisConfiguration.java

示例11: retrieveGraph

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Test
public void retrieveGraph() throws FileNotFoundException, UnsupportedEncodingException {
	when(healthIndicatorsAggregator.aggregateNodes())
			.thenReturn(Observable.from(newHashSet(
					node().withId("service1").havingLinkedToNodeIds(newHashSet("backend1")).build(),
					node().withId("service2").havingLinkedToNodeIds(newHashSet("backend2")).build(),
					node().withId("backend1").havingLinkedFromNodeIds(newHashSet("service1")).build(),
					node().withId("backend2").havingLinkedFromNodeIds(newHashSet("service2")).build())));
	when(indexesAggregator.aggregateNodes())
			.thenReturn(Observable.from(newHashSet(
					node().withId("svc1rsc1").havingLinkedToNodeIds(newHashSet("service1")).build(),
					node().withId("svc1rsc2").havingLinkedToNodeIds(newHashSet("service1")).build(),
					node().withId("svc2rsc1").havingLinkedToNodeIds(newHashSet("service2")).build(),
					node().withId("service1").withDetail("test", "test").build(),
					node().withId("service2").build())));
	when(pactsAggregator.aggregateNodes())
			.thenReturn(Observable.from(newHashSet(
					node().withId("svc1rsc2").build(),
					node().withId("svc2rsc1").build(),
					node().withId("service1").havingLinkedToNodeIds(newHashSet("svc2rsc1")).build(),
					node().withId("service2").havingLinkedToNodeIds(newHashSet("svc1rsc2")).build())));
	when(redisService.getAllNodes())
			.thenReturn(newHashSet());
	when(graphProperties.getUi()).thenReturn("UI Components");
	when(graphProperties.getResources()).thenReturn("Resources");
	when(graphProperties.getMicroservices()).thenReturn("Microservices");
	when(graphProperties.getBackends()).thenReturn("Backends");
	when(graphProperties.getTypes()).thenReturn(Arrays.asList(DB, MICROSERVICE, REST, SOAP, JMS, RESOURCE));

	long startTime = System.currentTimeMillis();
	Map<String, Object> graph = graphRetriever.retrieve();
	long totalTime = System.currentTimeMillis() - startTime;

	logger.info("Time spent waiting for processing: " + totalTime);
	GenericJackson2JsonRedisSerializer serializer = new GenericJackson2JsonRedisSerializer(new ObjectMapper());
	String nodeAsJson = new String(serializer.serialize(graph), "UTF-8");
	JSONAssert.assertEquals(removeBlankNodes(load("src/test/resources/GraphRetrieverTest.json")),
			removeBlankNodes(nodeAsJson), JSONCompareMode.LENIENT);
}
 
开发者ID:ordina-jworks,项目名称:microservices-dashboard-server,代码行数:40,代码来源:GraphRetrieverTest.java

示例12: testRedisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
@Test
public void testRedisTemplate() {
	assertThat(this.sessionRedisTemplate).isNotNull();
	assertThat(this.sessionRedisTemplate.getDefaultSerializer()).isNotNull();
	assertThat(this.sessionRedisTemplate.getDefaultSerializer())
			.isInstanceOf(GenericJackson2JsonRedisSerializer.class);
}
 
开发者ID:spring-projects,项目名称:spring-session,代码行数:8,代码来源:RedisSerializerTest.java

示例13: redisTemplate

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的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

示例14: setSerializer

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
private void setSerializer(RedisTemplate<String, String> template) {
    template.setDefaultSerializer(new GenericJackson2JsonRedisSerializer());
    template.setKeySerializer(new StringRedisSerializer());
    template.setHashKeySerializer(new GenericJackson2JsonRedisSerializer());
    template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
}
 
开发者ID:idreamshen,项目名称:spring-boot-with-multi-redis,代码行数:7,代码来源:RedisConfiguration.java

示例15: jacksonRedisSerializer

import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; //导入依赖的package包/类
/**
 * JSON序列化
 */
@Bean
public GenericJackson2JsonRedisSerializer jacksonRedisSerializer() {
	return new GenericJackson2JsonRedisSerializer();
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:8,代码来源:CoreCacheConfig.java


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