private List < Job > getJobs ( final Jedis jedis , final String queueName , final long jobOffset , final long jobCount ) throws Exception { final String key = key ( QUEUE , queueName ) ; final List < Job > jobs = new ArrayList <> ( ) ; if ( JedisUtils . isDelayedQueue ( jedis , key ) ) { // If delayed queue, use ZRANGEWITHSCORES final Set < Tuple > elements = jedis . zrangeWithScores ( key , jobOffset , jobOffset + jobCount - 1 ) ; for ( final Tuple elementWithScore : elements ) { final Job job = ObjectMapperFactory . get ( ) . readValue ( elementWithScore . getElement ( ) , Job . class ) ; job . setRunAt ( elementWithScore . getScore ( ) ) ; jobs . add ( job ) ; } } else { // Else, use LRANGE final List < String > elements = jedis . lrange ( key , jobOffset , jobOffset + jobCount - 1 ) ; for ( final String element : elements ) { jobs . add ( ObjectMapperFactory . get ( ) . readValue ( element , Job . class ) ) ; } } return jobs ; }
Get list of Jobs from a queue .