@Override
  public void produceResults(
      final Consumer<CloseableReference<CloseableImage>> consumer,
      final ProducerContext producerContext) {

    final ProducerListener2 listener = producerContext.getProducerListener();
    final ImageRequest imageRequest = producerContext.getImageRequest();
    final Object callerContext = producerContext.getCallerContext();

    // If there's no postprocessor or the postprocessor doesn't require caching, forward results.
    final Postprocessor postprocessor = imageRequest.getPostprocessor();
    if (postprocessor == null || postprocessor.getPostprocessorCacheKey() == null) {
      mInputProducer.produceResults(consumer, producerContext);
      return;
    }
    listener.onProducerStart(producerContext, getProducerName());
    final CacheKey cacheKey =
        mCacheKeyFactory.getPostprocessedBitmapCacheKey(imageRequest, callerContext);
    final boolean isBitmapCacheEnabledForRead =
        producerContext
            .getImageRequest()
            .isCacheEnabled(ImageRequest.CachesLocationsMasks.BITMAP_READ);

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

    if (cachedReference != null) {
      listener.onProducerFinishWithSuccess(
          producerContext,
          getProducerName(),
          listener.requiresExtraMap(producerContext, getProducerName())
              ? ImmutableMap.of(VALUE_FOUND, "true")
              : null);
      listener.onUltimateProducerReached(producerContext, PRODUCER_NAME, true);
      producerContext.putOriginExtra("memory_bitmap", "postprocessed");
      consumer.onProgressUpdate(1.0f);
      consumer.onNewResult(cachedReference, Consumer.IS_LAST);
      cachedReference.close();
    } else {
      final boolean isRepeatedProcessor = postprocessor instanceof RepeatedPostprocessor;
      final boolean isBitmapCacheEnabledForWrite =
          producerContext
              .getImageRequest()
              .isCacheEnabled(ImageRequest.CachesLocationsMasks.BITMAP_WRITE);
      Consumer<CloseableReference<CloseableImage>> cachedConsumer =
          new CachedPostprocessorConsumer(
              consumer, cacheKey, isRepeatedProcessor, mMemoryCache, isBitmapCacheEnabledForWrite);
      listener.onProducerFinishWithSuccess(
          producerContext,
          getProducerName(),
          listener.requiresExtraMap(producerContext, getProducerName())
              ? ImmutableMap.of(VALUE_FOUND, "false")
              : null);
      mInputProducer.produceResults(cachedConsumer, producerContext);
    }
  }
Memory cache producer for the bitmap memory cache.
imagepipeline/src/main/java/com/facebook/imagepipeline/producers/PostprocessedBitmapMemoryCacheProducer.java