Beispiel #1
0
  /**
   * Performs del request.
   *
   * @param key String key
   * @throws KVException with ERROR_NO_SUCH_KEY if key does not exist in store
   */
  @Override
  public void del(String key) throws KVException {
    if (key.length() > MAX_KEY_SIZE) {
      KVMessage msg = new KVMessage(KVConstants.RESP, ERROR_NO_SUCH_KEY);
      throw new KVException(msg);
    }

    Lock lock = dataCache.getLock(key);
    try {
      lock.lock();
      dataCache.del(key);
      dataStore.del(key);
    } finally {
      lock.unlock();
    }
  }