Package org.springframework.data.redis.serializer

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


  @Test
  public void testShouldBeAbleToUseRedisAtomicLongWithProperlyConfiguredRedisTemplate() {

    RedisTemplate<String, Long> template = new RedisTemplate<String, Long>();
    template.setConnectionFactory(factory);
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new GenericToStringSerializer<Long>(Long.class));
    template.afterPropertiesSet();

    RedisAtomicLong ral = new RedisAtomicLong("DATAREDIS-317.atomicLong", template);
    ral.set(32L);
View Full Code Here


  private RedisAtomicDouble(String redisCounter, RedisConnectionFactory factory, Double initialValue) {
    Assert.hasText(redisCounter, "a valid counter name is required");
    Assert.notNull(factory, "a valid factory is required");

    RedisTemplate<String, Double> redisTemplate = new RedisTemplate<String, Double>();
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new GenericToStringSerializer<Double>(Double.class));
    redisTemplate.setExposeConnection(true);
    redisTemplate.setConnectionFactory(factory);
    redisTemplate.afterPropertiesSet();
View Full Code Here

    this(redisCounter, template, Integer.valueOf(initialValue));
  }

  private RedisAtomicInteger(String redisCounter, RedisConnectionFactory factory, Integer initialValue) {
    RedisTemplate<String, Integer> redisTemplate = new RedisTemplate<String, Integer>();
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new GenericToStringSerializer<Integer>(Integer.class));
    redisTemplate.setExposeConnection(true);
    redisTemplate.setConnectionFactory(factory);
    redisTemplate.afterPropertiesSet();
View Full Code Here

  private RedisAtomicLong(String redisCounter, RedisConnectionFactory factory, Long initialValue) {
    Assert.hasText(redisCounter, "a valid counter name is required");
    Assert.notNull(factory, "a valid factory is required");

    RedisTemplate<String, Long> redisTemplate = new RedisTemplate<String, Long>();
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new GenericToStringSerializer<Long>(Long.class));
    redisTemplate.setExposeConnection(true);
    redisTemplate.setConnectionFactory(factory);
    redisTemplate.afterPropertiesSet();
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testExecuteBooleanResult() {
    this.template = new RedisTemplate<String, Long>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new GenericToStringSerializer<Long>(Long.class));
    template.setConnectionFactory(connFactory);
    template.afterPropertiesSet();
    DefaultRedisScript<Boolean> script = new DefaultRedisScript<Boolean>();
    script.setLocation(new ClassPathResource("org/springframework/data/redis/core/script/cas.lua"));
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes" })
  @Test
  public void testExecuteStatusResult() {
    this.template = new RedisTemplate<String, Long>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(new GenericToStringSerializer<Long>(Long.class));
    template.setConnectionFactory(connFactory);
    template.afterPropertiesSet();
    DefaultRedisScript script = new DefaultRedisScript();
    script.setScriptText("return redis.call('SET',KEYS[1], ARGV[1])");
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testExecuteCustomResultSerializer() {
    JacksonJsonRedisSerializer<Person> personSerializer = new JacksonJsonRedisSerializer<Person>(Person.class);
    this.template = new RedisTemplate<String, Person>();
    template.setKeySerializer(new StringRedisSerializer());
    template.setValueSerializer(personSerializer);
    template.setConnectionFactory(connFactory);
    template.afterPropertiesSet();
    DefaultRedisScript<String> script = new DefaultRedisScript<String>();
    script.setScriptSource(new StaticScriptSource("redis.call('SET',KEYS[1], ARGV[1])\nreturn 'FOO'"));
    script.setResultType(String.class);
    ScriptExecutor<String> scriptExecutor = new DefaultScriptExecutor<String>(template);
    Person joe = new Person("Joe", "Schmoe", 23);
    String result = scriptExecutor.execute(script, personSerializer, new StringRedisSerializer(),
        Collections.singletonList("bar"), joe);
    assertEquals("FOO", result);
    assertEquals(joe, template.boundValueOps("bar").get());
  }
View Full Code Here

    final DefaultRedisScript<String> script = new DefaultRedisScript<String>();
    script.setScriptText("return 'Hey'");
    script.setResultType(String.class);
    assertEquals(
        "Hey",
        redisTemplate.execute(script, redisTemplate.getValueSerializer(), new StringRedisSerializer(),
            Collections.singletonList(key1)));
  }
View Full Code Here

    this.name = name;
    this.template = template;
    this.prefix = prefix;
    this.expiration = expiration;

    StringRedisSerializer stringSerializer = new StringRedisSerializer();

    // name of the set holding the keys
    this.setName = stringSerializer.serialize(name + "~keys");
    this.cacheLockName = stringSerializer.serialize(name + "~lock");
  }
View Full Code Here

    RedisTemplate<String, String> stringTemplate = new StringRedisTemplate();
    stringTemplate.setConnectionFactory(jedisConnectionFactory);
    stringTemplate.afterPropertiesSet();

    RedisTemplate<String, Long> longTemplate = new RedisTemplate<String, Long>();
    longTemplate.setKeySerializer(new StringRedisSerializer());
    longTemplate.setValueSerializer(new GenericToStringSerializer<Long>(Long.class));
    longTemplate.setConnectionFactory(jedisConnectionFactory);
    longTemplate.afterPropertiesSet();

    RedisTemplate<String, Double> doubleTemplate = new RedisTemplate<String, Double>();
    doubleTemplate.setKeySerializer(new StringRedisSerializer());
    doubleTemplate.setValueSerializer(new GenericToStringSerializer<Double>(Double.class));
    doubleTemplate.setConnectionFactory(jedisConnectionFactory);
    doubleTemplate.afterPropertiesSet();

    RedisTemplate<byte[], byte[]> rawTemplate = new RedisTemplate<byte[], byte[]>();
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.