@SuppressWarnings({"squid:S1860", "squid:S6541", "squid:S3776"}) // Suppress synchronize warning
  public TimeseriesMetadata get(
      String filePath,
      TimeSeriesMetadataCacheKey key,
      Set<String> allSensors,
      boolean ignoreNotExists,
      boolean debug,
      QueryContext queryContext)
      throws IOException {
    long startTime = System.nanoTime();
    long loadBloomFilterTime = 0;
    LongConsumer timeSeriesMetadataIoSizeRecorder =
        queryContext.getQueryStatistics().getLoadTimeSeriesMetadataActualIOSize()::addAndGet;
    LongConsumer bloomFilterIoSizeRecorder =
        queryContext.getQueryStatistics().getLoadBloomFilterActualIOSize()::addAndGet;
    boolean cacheHit = true;
    try {
      if (!CACHE_ENABLE) {
        String deviceStringFormat = key.device.toString();
        cacheHit = false;

        // bloom filter part
        TsFileSequenceReader reader =
            FileReaderManager.getInstance().get(filePath, true, bloomFilterIoSizeRecorder);
        BloomFilter bloomFilter = reader.readBloomFilter(bloomFilterIoSizeRecorder);
        queryContext.getQueryStatistics().getLoadBloomFilterFromDiskCount().incrementAndGet();
        if (bloomFilter != null
            && !bloomFilter.contains(
                deviceStringFormat + IoTDBConstant.PATH_SEPARATOR + key.measurement)) {
          loadBloomFilterTime = System.nanoTime() - startTime;
          return null;
        }
        loadBloomFilterTime = System.nanoTime() - startTime;

        TimeseriesMetadata timeseriesMetadata =
            reader.readTimeseriesMetadata(
                key.device, key.measurement, ignoreNotExists, timeSeriesMetadataIoSizeRecorder);
        return (timeseriesMetadata == null || timeseriesMetadata.getStatistics().getCount() == 0)
            ? null
            : timeseriesMetadata;
      }

      TimeseriesMetadata timeseriesMetadata = lruCache.getIfPresent(key);

      if (timeseriesMetadata == null) {
        if (debug) {
          DEBUG_LOGGER.info("Cache miss: {}.{} in file: {}", key.device, key.measurement, filePath);
          DEBUG_LOGGER.info("Device: {}, all sensors: {}", key.device, allSensors);
        }
        String deviceStringFormat = key.device.toString();
        // allow for the parallelism of different devices
        synchronized (
            devices.computeIfAbsent(
                deviceStringFormat + SEPARATOR + filePath, WeakReference::new)) {
          // double check
          timeseriesMetadata = lruCache.getIfPresent(key);
          if (timeseriesMetadata == null) {
            cacheHit = false;

            long loadBloomFilterStartTime = System.nanoTime();
            // bloom filter part
            BloomFilter bloomFilter =
                BloomFilterCache.getInstance()
                    .get(
                        new BloomFilterCache.BloomFilterCacheKey(filePath, key.tsFileID),
                        debug,
                        bloomFilterIoSizeRecorder,
                        queryContext.getQueryStatistics().getLoadBloomFilterFromCacheCount()
                            ::addAndGet,
                        queryContext.getQueryStatistics().getLoadBloomFilterFromDiskCount()
                            ::addAndGet);
            if (bloomFilter != null
                && !bloomFilter.contains(
                    deviceStringFormat + TsFileConstant.PATH_SEPARATOR + key.measurement)) {
              if (debug) {
                DEBUG_LOGGER.info("TimeSeries meta data {} is filter by bloomFilter!", key);
              }
              loadBloomFilterTime = System.nanoTime() - loadBloomFilterStartTime;
              return null;
            }

            loadBloomFilterTime = System.nanoTime() - loadBloomFilterStartTime;
            TsFileSequenceReader reader =
                FileReaderManager.getInstance()
                    .get(filePath, true, timeSeriesMetadataIoSizeRecorder);
            List<TimeseriesMetadata> timeSeriesMetadataList =
                reader.readTimeseriesMetadata(
                    key.device,
                    key.measurement,
                    allSensors,
                    ignoreNotExists,
                    timeSeriesMetadataIoSizeRecorder);
            // put TimeSeriesMetadata of all sensors used in this read into cache
            for (TimeseriesMetadata metadata : timeSeriesMetadataList) {
              TimeSeriesMetadataCacheKey k =
                  new TimeSeriesMetadataCacheKey(
                      key.tsFileID, key.device, metadata.getMeasurementId());
              if (metadata.getStatistics().getCount() != 0) {
                lruCache.put(k, metadata);
              }
              if (metadata.getMeasurementId().equals(key.measurement)) {
                timeseriesMetadata = metadata.getStatistics().getCount() == 0 ? null : metadata;
              }
            }
          }
        }
      }
      if (timeseriesMetadata == null) {
        if (debug) {
          DEBUG_LOGGER.info("The file doesn't have this time series {}.", key);
        }
        return null;
      } else {
        if (debug) {
          DEBUG_LOGGER.info(
              "Get timeseries: {}.{}  metadata in file: {}  from cache: {}.",
              key.device,
              key.measurement,
              filePath,
              timeseriesMetadata);
        }
        return new TimeseriesMetadata(timeseriesMetadata);
      }
    } finally {
      queryContext.getQueryStatistics().getLoadBloomFilterTime().getAndAdd(loadBloomFilterTime);
      if (cacheHit) {
        queryContext
            .getQueryStatistics()
            .getLoadTimeSeriesMetadataFromCacheCount()
            .incrementAndGet();
        queryContext
            .getQueryStatistics()
            .getLoadTimeSeriesMetadataFromCacheTime()
            .getAndAdd(System.nanoTime() - startTime - loadBloomFilterTime);
      } else {
        queryContext
            .getQueryStatistics()
            .getLoadTimeSeriesMetadataFromDiskCount()
            .incrementAndGet();
        queryContext
            .getQueryStatistics()
            .getLoadTimeSeriesMetadataFromDiskTime()
            .getAndAdd(System.nanoTime() - startTime - loadBloomFilterTime);
      }
    }
  }
This class is used to cache <code>TimeSeriesMetadata</code> in IoTDB. The caching strategy is
LRU.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/buffer/TimeSeriesMetadataCache.java