public SQLAllTableConstraints getAllTableConstraints() {
      try {
        tableLock.readLock().lock();
        SQLAllTableConstraints constraints = new SQLAllTableConstraints();
        if (isConstraintsValid) {
          constraints.setPrimaryKeys(new ArrayList<>(this.primaryKeyCache.values()));
          constraints.setForeignKeys(new ArrayList<>(this.foreignKeyCache.values()));
          constraints.setNotNullConstraints(new ArrayList<>(this.notNullConstraintCache.values()));
          constraints.setUniqueConstraints(new ArrayList<>(this.uniqueConstraintCache.values()));
          constraints.setDefaultConstraints(new ArrayList<>(this.defaultConstraintCache.values()));
          constraints.setCheckConstraints(new ArrayList<>(this.checkConstraintCache.values()));
        }
        return constraints;
      } finally {
        tableLock.readLock().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