public boolean refreshDatabasesInCache(List<Database> databases) {
    if (isDatabaseCacheDirty.compareAndSet(true, false)) {
      LOG.debug("Skipping database cache update; the database list we have is dirty.");
      return false;
    }
    try {
      cacheLock.writeLock().lock();
      databaseCache.clear();
      for (Database db : databases) {
        addDatabaseToCache(db);
      }
      return true;
    } finally {
      cacheLock.writeLock().unlock();
    }
  }
Replaces the old db object with the new one. This will add the new database to cache if it does
not exist.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/SharedCache.java