List of usage examples for org.springframework.data.redis.core RedisTemplate RedisTemplate
public RedisTemplate()
RedisTemplate
instance. From source file:locksdemo.RedisUtils.java
static <K, V> RedisTemplate<K, V> createRedisTemplate(RedisConnectionFactory connectionFactory, Class<V> valueClass) { RedisTemplate<K, V> redisTemplate = new RedisTemplate<K, V>(); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new GenericToStringSerializer<V>(valueClass)); // avoids proxy redisTemplate.setExposeConnection(true); redisTemplate.setConnectionFactory(connectionFactory); redisTemplate.afterPropertiesSet();/*from w w w. j a v a 2 s. c om*/ return redisTemplate; }
From source file:net.acesinc.util.config.CacheConfig.java
@Bean public RedisTemplate<String, ContentResponse> redisTemplate(RedisConnectionFactory cf) { RedisTemplate<String, ContentResponse> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(cf); return redisTemplate; }
From source file:example.springdata.redis.repositories.ApplicationConfiguration.java
@Bean RedisTemplate<?, ?> redisTemplate(RedisConnectionFactory connectionFactory) { RedisTemplate<byte[], byte[]> template = new RedisTemplate<byte[], byte[]>(); template.setConnectionFactory(connectionFactory); return template; }
From source file:org.apache.camel.component.redis.RedisProducerIntegrationTest.java
@Override protected JndiRegistry createRegistry() throws Exception { JndiRegistry registry = super.createRegistry(); redisTemplate = new RedisTemplate(); redisTemplate.setConnectionFactory(CONNECTION_FACTORY); redisTemplate.afterPropertiesSet();//from w w w .java 2 s . c o m registry.bind("redisTemplate", redisTemplate); return registry; }
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/* w w w . j a v a 2 s . co m*/ 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:internal.diff.common.configuration.RedisConfiguration.java
@Bean public RedisTemplate<?, ?> redisTemplate() { RedisTemplate<?, ?> redisTemplate = new RedisTemplate(); redisTemplate.setConnectionFactory(redisConnectionFactory()); redisTemplate.setKeySerializer(new StringRedisSerializer()); return redisTemplate; }
From source file:org.encos.flydown.limiters.cache.impl.RedisRatingCache.java
@SuppressWarnings("unchecked") public RedisRatingCache(String ip, int port) { JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(); jedisConnectionFactory.setHostName(ip); jedisConnectionFactory.setPort(port); //todo to be defined properly cacheTemplate = new RedisTemplate(); cacheTemplate.setConnectionFactory(jedisConnectionFactory); }
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.coffeebeans.services.config.caching.RedisCachingConfig.java
@Bean RedisTemplate<Object, Object> redisTemplate() { RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); redisTemplate.setConnectionFactory(jedisConnectionFactory()); return redisTemplate; }
From source file:io.pivotal.ecosystem.servicebroker.Config.java
@Bean RedisTemplate<String, ServiceInstance> instanceTemplate(RedisConnectionFactory redisConnectionFactory) { RedisTemplate<String, ServiceInstance> template = new RedisTemplate<>(); template.setConnectionFactory(redisConnectionFactory); return template; }