Package org.springframework.data.redis.serializer

Examples of org.springframework.data.redis.serializer.StringRedisSerializer


*/
class RedisUtils {

  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);

View Full Code Here


    if (this.redisTemplate != null) {
      return this.redisTemplate;
    }
    RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
    template.setConnectionFactory(this.redisAvailableRule.getResource());
    template.setKeySerializer(new StringRedisSerializer());
    template.setEnableDefaultSerializer(false);
    template.afterPropertiesSet();
    this.redisTemplate = template;
    return template;
  }
View Full Code Here

  @Test
  public void testDefaultPayloadSerializer() throws Exception {
    RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
    template.setConnectionFactory(connectionFactory);
    template.setKeySerializer(new StringRedisSerializer());
    template.afterPropertiesSet();

    adapter.afterPropertiesSet();
    adapter.start();
View Full Code Here

  }

  @Test
  public void testDefaultMsgSerializer() throws Exception {
    RedisTemplate<String, Message<String>> template = new RedisTemplate<String, Message<String>>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new JdkSerializationRedisSerializer());
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();

    adapter.setExpectMessage(true);
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testNoSerializer() throws Exception {
    RedisTemplate<String, byte[]> template = new RedisTemplate<String, byte[]>();
    template.setEnableDefaultSerializer(false);
    template.setKeySerializer(new StringRedisSerializer());
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();

    adapter.setSerializer(null);
    adapter.afterPropertiesSet();
View Full Code Here

  @Test(expected = IllegalArgumentException.class)
  public void testNoSerializerNoExtractPayload() throws Exception {
    RedisTemplate<String, byte[]> template = new RedisTemplate<String, byte[]>();
    template.setEnableDefaultSerializer(false);
    template.setKeySerializer(new StringRedisSerializer());
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();

    adapter.setSerializer(null);
    adapter.setExpectMessage(true);
View Full Code Here

  }

  @Test
  public void testCustomPayloadSerializer() throws Exception {
    RedisTemplate<String, Long> template = new RedisTemplate<String, Long>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new GenericToStringSerializer<Long>(Long.class));
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();

    adapter.setSerializer(new GenericToStringSerializer<Long>(Long.class));
View Full Code Here

  }

  @Test
  public void testCustomMessageSerializer() throws Exception {
    RedisTemplate<String, Message<?>> template = new RedisTemplate<String, Message<?>>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new TestMessageSerializer());
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();

    adapter.setSerializer(new TestMessageSerializer());
View Full Code Here

  }

  @Test
  public void testDefaultMsgSerializer() throws Exception {
    RedisTemplate<String, Message<?>> template = new RedisTemplate<String, Message<?>>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new JdkSerializationRedisSerializer());
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();

    adapter.setExtractPayload(false);
View Full Code Here

  @Test
  public void testNoSerializer() throws Exception {
    RedisTemplate<String, byte[]> template = new RedisTemplate<String, byte[]>();
    template.setEnableDefaultSerializer(false);
    template.setKeySerializer(new StringRedisSerializer());
    template.setConnectionFactory(connectionFactory);
    template.afterPropertiesSet();

    adapter.afterPropertiesSet();
View Full Code Here

TOP

Related Classes of org.springframework.data.redis.serializer.StringRedisSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.