Package org.springframework.data.redis.connection

Examples of org.springframework.data.redis.connection.SortParameters$Range


    return sort(query, valueSerializer);
  }

  public <T> List<T> sort(SortQuery<K> query, RedisSerializer<T> resultSerializer) {
    final byte[] rawKey = rawKey(query.getKey());
    final SortParameters params = QueryUtils.convertQuery(query, stringSerializer);

    List<byte[]> vals = execute(new RedisCallback<List<byte[]>>() {

      public List<byte[]> doInRedis(RedisConnection connection) throws DataAccessException {
        return connection.sort(rawKey, params);
View Full Code Here


  }

  public Long sort(SortQuery<K> query, K storeKey) {
    final byte[] rawStoreKey = rawKey(storeKey);
    final byte[] rawKey = rawKey(query.getKey());
    final SortParameters params = QueryUtils.convertQuery(query, stringSerializer);

    return execute(new RedisCallback<Long>() {

      public Long doInRedis(RedisConnection connection) throws DataAccessException {
        return connection.sort(rawKey, params, rawStoreKey);
View Full Code Here

@SuppressWarnings("deprecation")
public class SrpUtilsTests {

  @Test
  public void testSortParamsWithAllParams() {
    SortParameters sortParams = new DefaultSortParameters().alpha().asc().by("weight_*".getBytes())
        .get("object_*".getBytes()).limit(0, 5);
    Object[] sort = SrpUtils.sortParams(sortParams, "foo".getBytes());
    assertArrayEquals(
        new String[] { "BY", "weight_*", "LIMIT 0 5", "GET", "object_*", "ASC", "ALPHA", "STORE", "foo" },
        convertByteArrays(sort));
View Full Code Here

        convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyBy() {
    SortParameters sortParams = new DefaultSortParameters().numeric().by("weight_*".getBytes());
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "BY", "weight_*" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "BY", "weight_*" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyLimit() {
    SortParameters sortParams = new DefaultSortParameters().numeric().limit(0, 5);
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "LIMIT 0 5" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "LIMIT 0 5" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyGetPatterns() {
    SortParameters sortParams = new DefaultSortParameters().numeric().get("foo".getBytes()).get("bar".getBytes());
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "GET", "foo", "GET", "bar" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "GET", "foo", "GET", "bar" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyOrder() {
    SortParameters sortParams = new DefaultSortParameters().numeric().desc();
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "DESC" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "DESC" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyAlpha() {
    SortParameters sortParams = new DefaultSortParameters().alpha();
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "ALPHA" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "ALPHA" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyStore() {
    SortParameters sortParams = new DefaultSortParameters().numeric();
    Object[] sort = SrpUtils.sortParams(sortParams, "storelist".getBytes());
    assertArrayEquals(new String[] { "STORE", "storelist" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "STORE", "storelist" }, convertByteArrays(sort));
  }

  @Test
  public void testSortWithAllParams() {
    SortParameters sortParams = new DefaultSortParameters().alpha().asc().by("weight_*".getBytes())
        .get("object_*".getBytes()).limit(0, 5);
    byte[] sort = SrpUtils.sort(sortParams, "foo".getBytes());
    assertEquals("BY weight_* LIMIT 0 5 GET object_* ASC ALPHA STORE foo", new String(sort));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.redis.connection.SortParameters$Range

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.