List of usage examples for org.springframework.data.redis.core RedisTemplate setConnectionFactory
public void setConnectionFactory(RedisConnectionFactory connectionFactory)
From source file:com.vcredit.lrh.db.redis.RedisCacheConfiguration.java
@Bean(name = "redisTemplate") public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(redisConnectionFactory); return redisTemplate; }
From source file:lab.home.spring.redis.test.RedisTestConfig.java
@Bean RedisTemplate<String, Object> redisTemplate() { final RedisTemplate<String, Object> template = new RedisTemplate<String, Object>(); template.setConnectionFactory(jedisConnectionFactory()); template.setKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new GenericToStringSerializer<Object>(Object.class)); template.setValueSerializer(new GenericToStringSerializer<Object>(Object.class)); return template; }
From source file:com.miko.demo.mongo.service.RedisRemovalTest.java
@Test public void removalKeyValueTest() { RedisTemplate<String, Long> redis = new RedisTemplate<>(); redis.setConnectionFactory(connectionFactory); redis.setKeySerializer(RedisStringSerializer.INSTANCE); redis.setValueSerializer(RedisLongSerializer.INSTANCE); redis.afterPropertiesSet();// ww w. j a v a2s .co m ValueOperations<String, Long> ops = redis.opsForValue(); String key1 = "miko-spring-mongo:counter-test"; String key2 = "miko-spring-mongo:counter-test-2"; Set<String> keys = redis.keys(key1); for (String foundKey : keys) { logger.debug("Found Key= " + foundKey + " value= " + ops.get(foundKey)); } redis.delete(key2); }
From source file:com.miko.demo.postgresql.service.RedisRemovalTest.java
@Test public void removalKeyValueTest() { RedisTemplate<String, Long> redis = new RedisTemplate<>(); redis.setConnectionFactory(connectionFactory); redis.setKeySerializer(RedisStringSerializer.INSTANCE); redis.setValueSerializer(RedisLongSerializer.INSTANCE); redis.afterPropertiesSet();//ww w. j a v a2 s. c o m ValueOperations<String, Long> ops = redis.opsForValue(); String key1 = "miko-spring-postgresql:counter-test"; String key2 = "miko-spring-postgresql:counter-test-2"; Set<String> keys = redis.keys(key1); for (String foundKey : keys) { logger.debug("Found Key= " + foundKey + " value= " + ops.get(foundKey)); } redis.delete(key2); }
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:am.ik.categolj3.api.entry.redis.EntryRedisTemplateFactory.java
public RedisTemplate<Object, Object> create() { RedisTemplate<Object, Object> template = new RedisTemplate<>(); template.setConnectionFactory(redisConnectionFactory); template.setKeySerializer(new JdkSerializationRedisSerializer()); template.setValueSerializer(new RedisSerializer<Entry>() { @Override/*from www . j a v a 2 s . c om*/ public byte[] serialize(Entry entry) throws SerializationException { if (entry == null) { return new byte[0]; } try { return objectMapper.writeValueAsBytes(entry); } catch (JsonProcessingException e) { throw new SerializationException("Cannot serialize " + entry, e); } } @Override public Entry deserialize(byte[] bytes) throws SerializationException { if (bytes == null || bytes.length == 0) { return null; } try { return objectMapper.readValue(bytes, Entry.class); } catch (IOException e) { throw new SerializationException("Cannot deserialize " + Arrays.toString(bytes), e); } } }); return template; }
From source file:curly.commons.config.cache.RedisCacheConfig.java
@Bean RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) { RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(connectionFactory); return redisTemplate; }
From source file:com.hp.autonomy.frontend.find.hod.beanconfiguration.RedisConfiguration.java
@Bean public RedisTemplate<Object, Object> cachingRedisTemplate() { final RedisTemplate<Object, Object> template = new RedisTemplate<>(); template.setConnectionFactory(redisConnectionFactory()); return template; }
From source file:org.cloudfoundry.community.servicebroker.vrealize.CloudConfig.java
@Bean @Qualifier("siTemplate") RedisTemplate<String, VrServiceInstance> siTemplate() { RedisTemplate<String, VrServiceInstance> template = new RedisTemplate<String, VrServiceInstance>(); template.setConnectionFactory(jedisConnectionFactory()); return template; }
From source file:com.ge.predix.acs.config.CloudRedisConfig.java
@Bean public RedisTemplate<String, String> redisTemplate() { RedisTemplate<String, String> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(redisConnectionFactory()); redisTemplate.setDefaultSerializer(new StringRedisSerializer()); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new StringRedisSerializer()); LOGGER.info("Successfully created Redis template."); return redisTemplate; }