org.springframework.data.redis.core.DefaultTypedTuple Java Examples

The following examples show how to use org.springframework.data.redis.core.DefaultTypedTuple. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RqueueQDetailServiceImpl.java    From rqueue with Apache License 2.0 5 votes vote down vote up
private List<TypedTuple<RqueueMessage>> readFromZset(
    String name, int pageNumber, int itemPerPage) {
  long start = pageNumber * (long) itemPerPage;
  long end = start + itemPerPage - 1;

  return rqueueMessageTemplate.readFromZset(name, start, end).stream()
      .map(e -> new DefaultTypedTuple<>(e, null))
      .collect(Collectors.toList());
}
 
Example #2
Source File: RqueueQDetailServiceImpl.java    From rqueue with Apache License 2.0 5 votes vote down vote up
private List<TypedTuple<RqueueMessage>> readFromList(
    String name, int pageNumber, int itemPerPage) {
  long start = pageNumber * (long) itemPerPage;
  long end = start + itemPerPage - 1;
  return rqueueMessageTemplate.readFromList(name, start, end).stream()
      .map(e -> new DefaultTypedTuple<>(e, null))
      .collect(Collectors.toList());
}
 
Example #3
Source File: RqueueQDetailServiceTest.java    From rqueue with Apache License 2.0 5 votes vote down vote up
@Test
public void viewDataZset() {
  Set<TypedTuple<Object>> objects = new HashSet<>();
  objects.add(new DefaultTypedTuple<>("Test", 100.0));
  objects.add(
      new DefaultTypedTuple<>(
          RqueueMessageFactory.buildMessage(null, "jobs", null, null), 200.0));

  List<List<Serializable>> rows = new ArrayList<>();
  for (TypedTuple<Object> typedTuple : objects) {
    List<Serializable> row = new ArrayList<>();
    row.add(String.valueOf(typedTuple.getValue()));
    row.add(typedTuple.getScore());
    rows.add(row);
  }
  DataViewResponse expectedResponse = new DataViewResponse();
  List<String> headers = new ArrayList<>();
  headers.add("Item");
  headers.add("Score");
  expectedResponse.setHeaders(headers);

  expectedResponse.setRows(rows);

  doReturn(objects).when(stringRqueueRedisTemplate).zrangeWithScore("jobs", 0, 9);
  DataViewResponse response = rqueueQDetailService.viewData("jobs", DataType.ZSET, null, 0, 10);

  assertEquals(expectedResponse, response);
}
 
Example #4
Source File: RedisDelayBucket.java    From Milkomeda with MIT License 5 votes vote down vote up
@Override
public void add(List<DelayJob> delayJobs) {
    String bucketName = getCurrentBucketName();
    BoundZSetOperations<String, String> bucket = getBucket(bucketName);
    Set<ZSetOperations.TypedTuple<String>> delayJobSet = delayJobs.stream()
            .map(delayJob -> new DefaultTypedTuple<>(delayJob.toSimple(), (double) delayJob.getDelayTime()))
            .collect(Collectors.toSet());
    bucket.add(delayJobSet);
}
 
Example #5
Source File: RedisTest.java    From spring-boot-cookbook with Apache License 2.0 5 votes vote down vote up
@Test
public void testTypedTuple() {

    Set<DefaultTypedTuple<Integer>> typedTupleSet = new HashSet<>();
    ArrayList<Integer> source = newArrayList(1, 2, 3, 4, 5, 6);
    for (int i = 0; i < source.size(); i++) {
        DefaultTypedTuple<Integer> typedTuple = new DefaultTypedTuple<>(source.get(i), i + 100.0);
        typedTupleSet.add(typedTuple);
    }
    BoundZSetOperations myzset = redisTemplate.boundZSetOps("myzset");
    myzset.add(typedTupleSet);
    System.out.println(myzset.range(0, -1));
}