private Optional<List<Id>> generateIdsUsingRedis(final Redis redis,final long batchSize){
  Optional<IcicleRedisResponse> optionalIcicleRedisResponse=executeOrLoadLuaScript(redis,batchSize);
  if (!optionalIcicleRedisResponse.isPresent()) {
    return Optional.absent();
  }
  IcicleRedisResponse icicleRedisResponse=optionalIcicleRedisResponse.get();
  long timestamp=(icicleRedisResponse.getTimeSeconds() * ONE_MILLI_IN_MICRO_SECS) + (icicleRedisResponse.getTimeMicroseconds() / ONE_MILLI_IN_MICRO_SECS);
  long logicalShardId=icicleRedisResponse.getLogicalShardId();
  validateLogicalShardId(logicalShardId);
  List<Id> ids=new ArrayList<>();
  for (long i=icicleRedisResponse.getStartSequence(); i <= icicleRedisResponse.getEndSequence(); i++) {
    long id=((timestamp - CUSTOM_EPOCH) << TIMESTAMP_SHIFT) | (logicalShardId << LOGICAL_SHARD_ID_SHIFT) | i;
    ids.add(new Id(id,timestamp));
  }
  return Optional.of(ids);
}

private Optional < List < Id > > generateIdsUsingRedis ( final Redis redis , final long batchSize ) { Optional < IcicleRedisResponse > optionalIcicleRedisResponse = executeOrLoadLuaScript ( redis , batchSize ) ; if ( ! optionalIcicleRedisResponse . isPresent ( ) ) { return Optional . absent ( ) ; } IcicleRedisResponse icicleRedisResponse = optionalIcicleRedisResponse . get ( ) ; long timestamp = ( icicleRedisResponse . getTimeSeconds ( ) * ONE_MILLI_IN_MICRO_SECS ) + ( icicleRedisResponse . getTimeMicroseconds ( ) / ONE_MILLI_IN_MICRO_SECS ) ; long logicalShardId = icicleRedisResponse . getLogicalShardId ( ) ; validateLogicalShardId ( logicalShardId ) ; List < Id > ids = new ArrayList < > ( ) ; for ( long i = icicleRedisResponse . getStartSequence ( ) ; i <= icicleRedisResponse . getEndSequence ( ) ; i ++ ) { long id = ( ( timestamp - CUSTOM_EPOCH ) << TIMESTAMP_SHIFT ) | ( logicalShardId << LOGICAL_SHARD_ID_SHIFT ) | i ; ids . add ( new Id ( id , timestamp ) ) ; } return Optional . of ( ids ) ; }
generate an id using the given redis instance .
