Package org.springframework.data.redis.serializer

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


  @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.setExtractPayload(false);
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

    this.connectionFactory = redisAvailableRule.getResource();
  }

  @Test
  public void testWithDefaultSerializer() throws Exception {
    setupListener(new StringRedisSerializer());
    final RedisPublishingMessageHandler handler = new RedisPublishingMessageHandler(connectionFactory);
    handler.setBeanFactory(BusTestUtils.MOCK_BF);
    handler.setTopic(TOPIC);
    handler.afterPropertiesSet();
    for (int i = 0; i < NUM_MESSAGES; i++) {
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

   */
  public RedisAggregateCounterRepository(RedisConnectionFactory redisConnectionFactory) {
    super("aggregatecounters", redisConnectionFactory);
    RedisTemplate<String, String> redisTemplate = new RedisTemplate<String, String>();
    redisTemplate.setConnectionFactory(redisConnectionFactory);
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new StringRedisSerializer());
    redisTemplate.setHashKeySerializer(new StringRedisSerializer());
    redisTemplate.setHashValueSerializer(new GenericToStringSerializer<Long>(Long.class));
    redisTemplate.afterPropertiesSet();
    hashOperations = redisTemplate.opsForHash();
    setOperations = redisTemplate.opsForSet();
  }
View Full Code Here

    }

    @Bean
    public RedisTemplate<String,ExpiringSession> sessionRedisTemplate(RedisConnectionFactory connectionFactory) {
        RedisTemplate<String, ExpiringSession> template = new RedisTemplate<String, ExpiringSession>();
        template.setKeySerializer(new StringRedisSerializer());
        template.setHashKeySerializer(new StringRedisSerializer());
        template.setConnectionFactory(connectionFactory);
        return template;
    }
View Full Code Here

    }

    @Bean
    public RedisTemplate<String,String> expirationRedisTemplate(RedisConnectionFactory connectionFactory) {
        RedisTemplate<String, String> template = new RedisTemplate<String, String>();
        template.setKeySerializer(new StringRedisSerializer());
        template.setHashKeySerializer(new StringRedisSerializer());
        template.setConnectionFactory(connectionFactory);
        return template;
    }
View Full Code Here

    @SuppressWarnings("rawtypes")
    private static RedisTemplate createDefaultTemplate(RedisConnectionFactory connectionFactory) {
        Assert.notNull(connectionFactory,"connectionFactory cannot be null");
        RedisTemplate<String, ExpiringSession> template = new RedisTemplate<String, ExpiringSession>();
        template.setKeySerializer(new StringRedisSerializer());
        template.setHashKeySerializer(new StringRedisSerializer());
        template.setConnectionFactory(connectionFactory);
        return template;
    }
View Full Code Here

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

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.