RedisStorageService extends AbstractStorageService { @Override public List<AwesomeJob> listExpiredJobs(long currentTime) { try (Jedis jedis = jedisPool.getResource()){ Set<String> jobSet = jedis.zrangeByScore(RedisConstants.generateDelayBucketKey(),0,currentTime); List<AwesomeJob> expiredList = new ArrayList<>(jobSet.size()); for (String id: jobSet){ String json = jedis.get(RedisConstants.generateJobKey(id)); if (RedisConstants.isEmpty(json)){ break; } AwesomeJob job = JSON.parseObject(json,AwesomeJob.class); if (job.getStatus() == RedisConstants.JobStatus.delay.getValue()){ expiredList.add(job); } } return expiredList; } } RedisStorageService(AwesomeURL url); @Override AwesomeJob getJob(String id); @Override void removeJob(String id); @Override List<AwesomeJob> listExpiredJobs(long currentTime); @Override List<AwesomeJob> listCountdownJobs(); @Override void countdownJob(String jobId); @Override void transferExpiredJobs(List<AwesomeJob> jobList); @Override List<AwesomeJob> consumeReadyJobs(String topic,int number); @Override boolean addAwesomeTopic(AwesomeTopic topic); @Override AwesomeTopic getAwesomeTopic(String topic);  }
@Test public void test(){ Map<String,String> param = new HashMap<>(); AwesomeURL url = new AwesomeURL("redis",null,null,"13.114.39.142",6379,null,param); StorageService storageService = new RedisStorageFactory().createStorageService(url); List<AwesomeJob> list = storageService.listExpiredJobs(System.currentTimeMillis()); for (AwesomeJob job1 :list){ System.out.println(job1.toString()); } }