code: private <T> T doWithLock(LockCallback<T> callback, String errorMessage) throws JobPersistenceException {
          JedisCommands jedis = null;
          try {
              jedis = getResource();
              try {
                  storage.waitForLock(jedis);
                  return callback.doWithLock(jedis);
              } catch (ObjectAlreadyExistsException e) {
                  throw e;
              } catch (Exception e) {
                  if (errorMessage == null || errorMessage.isEmpty()) {
                      errorMessage = "Job storage error.";
                  }
                  throw new JobPersistenceException(errorMessage, e);
              } finally {
                  storage.unlock(jedis);
              }
          } finally {
              if (jedis != null && jedis instanceof Jedis) {
                  // only close if we're not using a JedisCluster instance
                  ((Jedis) jedis).close();
              }
          }
      }
docs: Perform a redis operation while lock is acquired
  @param callback a callback containing the actions to perform during lock
  @param errorMessage optional error message to include in exception should an error arise
  @param <T> return class
  @return the result of the actions performed while locked, if any
  @throws JobPersistenceException