public void removeConstraint(String name) {
      try {
        tableLock.writeLock().lock();
        Object constraint = null;
        MemberName mn = null;
        Class constraintClass = null;
        name = StringUtils.normalizeIdentifier(name);
        if (this.primaryKeyCache.containsKey(name)) {
          constraint = this.primaryKeyCache.remove(name);
          mn = MemberName.PRIMARY_KEY_CACHE;
          constraintClass = SQLPrimaryKey.class;
        } else if (this.foreignKeyCache.containsKey(name)) {
          constraint = this.foreignKeyCache.remove(name);
          mn = MemberName.FOREIGN_KEY_CACHE;
          constraintClass = SQLForeignKey.class;
        } else if (this.notNullConstraintCache.containsKey(name)) {
          constraint = this.notNullConstraintCache.remove(name);
          mn = MemberName.NOTNULL_CONSTRAINT_CACHE;
          constraintClass = SQLNotNullConstraint.class;
        } else if (this.uniqueConstraintCache.containsKey(name)) {
          constraint = this.uniqueConstraintCache.remove(name);
          mn = MemberName.UNIQUE_CONSTRAINT_CACHE;
          constraintClass = SQLUniqueConstraint.class;
        } else if (this.defaultConstraintCache.containsKey(name)) {
          constraint = this.defaultConstraintCache.remove(name);
          mn = MemberName.DEFAULT_CONSTRAINT_CACHE;
          constraintClass = SQLDefaultConstraint.class;
        } else if (this.checkConstraintCache.containsKey(name)) {
          constraint = this.checkConstraintCache.remove(name);
          mn = MemberName.CHECK_CONSTRAINT_CACHE;
          constraintClass = SQLCheckConstraint.class;
        }

        if (constraint == null) {
          LOG.debug("Constraint: " + name + " does not exist in cache.");
          return;
        }
        setMemberCacheUpdated(mn, true);
        int size = getObjectSize(constraintClass, constraint);
        updateMemberSize(mn, -1 * size, SizeMode.Delta);
      } finally {
        tableLock.writeLock().unlock();
      }
    }
Common method to cache constraints
@param constraintsList list of constraints to add to cache
@param fromPrewarm is this method called as part of prewarm phase
@param mn Constraint type
@return memory constraint is handled by cache eviction policy hence this method will always return true
if correct constraint type is provided.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java