@Override
  public void produceResults(
      final Consumer<CloseableReference<CloseableImage>> consumer,
      final ProducerContext producerContext) {
    try {
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.beginSection("BitmapMemoryCacheProducer#produceResults");
      }
      final ProducerListener2 listener = producerContext.getProducerListener();
      listener.onProducerStart(producerContext, getProducerName());
      final ImageRequest imageRequest = producerContext.getImageRequest();
      final Object callerContext = producerContext.getCallerContext();
      final CacheKey cacheKey = mCacheKeyFactory.getBitmapCacheKey(imageRequest, callerContext);
      final boolean isBitmapCacheEnabledForRead =
          producerContext
              .getImageRequest()
              .isCacheEnabled(ImageRequest.CachesLocationsMasks.BITMAP_READ);

      CloseableReference<CloseableImage> cachedReference =
          isBitmapCacheEnabledForRead ? mMemoryCache.get(cacheKey) : null;

      if (cachedReference != null) {
        maybeSetExtrasFromCloseableImage(cachedReference.get(), producerContext);
        boolean isFinal = cachedReference.get().getQualityInfo().isOfFullQuality();
        if (isFinal) {
          listener.onProducerFinishWithSuccess(
              producerContext,
              getProducerName(),
              listener.requiresExtraMap(producerContext, getProducerName())
                  ? ImmutableMap.of(EXTRA_CACHED_VALUE_FOUND, "true")
                  : null);
          listener.onUltimateProducerReached(producerContext, getProducerName(), true);
          producerContext.putOriginExtra("memory_bitmap", getOriginSubcategory());
          consumer.onProgressUpdate(1f);
        }
        consumer.onNewResult(cachedReference, BaseConsumer.simpleStatusForIsLast(isFinal));
        cachedReference.close();
        if (isFinal) {
          return;
        }
      }

      if (producerContext.getLowestPermittedRequestLevel().getValue()
          >= ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE.getValue()) {
        listener.onProducerFinishWithSuccess(
            producerContext,
            getProducerName(),
            listener.requiresExtraMap(producerContext, getProducerName())
                ? ImmutableMap.of(EXTRA_CACHED_VALUE_FOUND, "false")
                : null);
        listener.onUltimateProducerReached(producerContext, getProducerName(), false);
        producerContext.putOriginExtra("memory_bitmap", getOriginSubcategory());
        consumer.onNewResult(null, Consumer.IS_LAST);
        return;
      }

      Consumer<CloseableReference<CloseableImage>> wrappedConsumer =
          wrapConsumer(
              consumer,
              cacheKey,
              producerContext
                  .getImageRequest()
                  .isCacheEnabled(ImageRequest.CachesLocationsMasks.BITMAP_WRITE));
      listener.onProducerFinishWithSuccess(
          producerContext,
          getProducerName(),
          listener.requiresExtraMap(producerContext, getProducerName())
              ? ImmutableMap.of(EXTRA_CACHED_VALUE_FOUND, "false")
              : null);
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.beginSection("mInputProducer.produceResult");
      }
      mInputProducer.produceResults(wrappedConsumer, producerContext);
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.endSection();
      }
    } finally {
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.endSection();
      }
    }
  }
Memory cache producer for the bitmap memory cache.
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/BitmapMemoryCacheProducer.java