private boolean refreshConstraint(List constraints, MemberName mn) {

      int size = 0;
      switch (mn) {
      case PRIMARY_KEY_CACHE:
        Map<String, SQLPrimaryKey> newPk = new ConcurrentHashMap<>();
        if (!CollectionUtils.isEmpty(constraints)) {
          for (SQLPrimaryKey key : (List<SQLPrimaryKey>) constraints) {
            String pkName = StringUtils.normalizeIdentifier(key.getPk_name());
            key.setPk_name(pkName);
            newPk.put(pkName, key);
            size += getObjectSize(SQLPrimaryKey.class, key);
          }
        }
        primaryKeyCache = newPk;
        break;
      case FOREIGN_KEY_CACHE:
        Map<String, SQLForeignKey> newFk = new ConcurrentHashMap<>();
        if (!CollectionUtils.isEmpty(constraints)) {
          for (SQLForeignKey key : (List<SQLForeignKey>) constraints) {
            String fkName = StringUtils.normalizeIdentifier(key.getFk_name());
            key.setFk_name(fkName);
            newFk.put(fkName, key);
            size += getObjectSize(SQLForeignKey.class, key);
          }
        }
        foreignKeyCache = newFk;
        break;
      case UNIQUE_CONSTRAINT_CACHE:
        Map<String, SQLUniqueConstraint> newUc = new ConcurrentHashMap<>();
        if (!CollectionUtils.isEmpty(constraints)) {
          for (SQLUniqueConstraint constraint : (List<SQLUniqueConstraint>) constraints) {
            String ucName = StringUtils.normalizeIdentifier(constraint.getUk_name());
            constraint.setUk_name(ucName);
            newUc.put(ucName, constraint);
            size += getObjectSize(SQLUniqueConstraint.class, constraint);
          }
        }
        uniqueConstraintCache = newUc;
        break;
      case NOTNULL_CONSTRAINT_CACHE:
        Map<String, SQLNotNullConstraint> newNn = new ConcurrentHashMap<>();
        if (!CollectionUtils.isEmpty(constraints)) {
          for (SQLNotNullConstraint constraint : (List<SQLNotNullConstraint>) constraints) {
            String nnName = StringUtils.normalizeIdentifier(constraint.getNn_name());
            constraint.setNn_name(nnName);
            newNn.put(nnName, constraint);
            size += getObjectSize(SQLNotNullConstraint.class, constraint);
          }
        }
        notNullConstraintCache = newNn;
        break;
      case DEFAULT_CONSTRAINT_CACHE:
        Map<String, SQLDefaultConstraint> newDc = new ConcurrentHashMap<>();
        if (!CollectionUtils.isEmpty(constraints)) {
          for (SQLDefaultConstraint constraint : (List<SQLDefaultConstraint>) constraints) {
            String dcName = StringUtils.normalizeIdentifier(constraint.getDc_name());
            constraint.setDc_name(dcName);
            newDc.put(dcName, constraint);
            size += getObjectSize(SQLDefaultConstraint.class, constraint);
          }
        }
        defaultConstraintCache = newDc;
        break;
      case CHECK_CONSTRAINT_CACHE:
        Map<String, SQLCheckConstraint> newCc = new ConcurrentHashMap<>();
        if (!CollectionUtils.isEmpty(constraints)) {
          for (SQLCheckConstraint constraint : (List<SQLCheckConstraint>) constraints) {
            String ccName = StringUtils.normalizeIdentifier(constraint.getDc_name());
            constraint.setDc_name(ccName);
            newCc.put(ccName, constraint);
            size += getObjectSize(SQLCheckConstraint.class, constraint);
          }
        }
        checkConstraintCache = newCc;
        break;
      default:
        LOG.error("Should not reach here");
        return false;
      }
      updateMemberSize(mn, size, SizeMode.Snapshot);
      LOG.debug("{}  refresh was successful for {}.{}.{}", mn, this.getTable().getCatName(),
          this.getTable().getDbName(), this.getTable().getTableName());
      return true;
    }
Common method to refresh cache constraint
@param constraints list of constraints to update
@param mn Constraint type
@return Since memory constraint is handled by cache eviction policy.
Hence this method will always return true if correct constraint type passed.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java