class SimpleMongoLock extends AbstractSimpleLock {

  @Override
  protected String acquire(final String key, final String storeId, final String token, final long expiration) {
    final var query = Query.query(Criteria.where("_id").is(key));
    final var update = new Update()
      .setOnInsert("_id", key)
      .setOnInsert("expireAt", LocalDateTime.now().plus(expiration, ChronoUnit.MILLIS))
      .setOnInsert("token", token);

    final var options = new FindAndModifyOptions().upsert(true).returnNew(true);
    final var doc = mongoTemplate.findAndModify(query, update, options, LockDocument.class, storeId);

    final var locked = doc.getToken().equals(token);
    log.debug("Tried to acquire lock for key {} with token {} in store {}. Locked: {}", key, token, storeId, locked);
    return locked ? token : null;
  }

  public  SimpleMongoLock(final Supplier<String> tokenSupplier, final MongoTemplate mongoTemplate);

}