} else { //this means previousReceiptHandle == null and nextReceiptHandle != null. Retrieve id backward
//return result will exclude the nextReceiptHandle
//retrieve nextReceiptHandle, get index. if not exist, retrieve from beginning.
Long endRank = jedis.zrank(key, nextReceiptHandle);
if (endRank == null) {
memIds = jedis.zrangeByScore(key, System.currentTimeMillis() - retention * 1000L, System.currentTimeMillis(), 0, num);
if (memIds != null){
memIdsRet = new ArrayList<String>(memIds);
}
}
//if index exist, retrieve based on index. When get result, remove expired id