diff --git a/core/core.services.yml b/core/core.services.yml
index a4327bda9b..dc0cdfaa71 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -261,6 +261,8 @@ services:
     class: Drupal\Core\EventSubscriber\CacheRouterRebuildSubscriber
     tags:
       - { name: event_subscriber }
+  memory_cache.factory:
+    class: Drupal\Core\Cache\MemoryCache\MemoryCacheFactory
   page_cache_request_policy:
     class: Drupal\Core\PageCache\DefaultRequestPolicy
     arguments: ['@session_configuration']
@@ -552,7 +554,10 @@ services:
     class: Drupal\Core\Entity\EntityManager
     parent: container.trait
   entity.memory_cache:
-    class: Drupal\Core\Cache\MemoryCache\MemoryCache
+    class: Drupal\Core\Cache\MemoryCache\MemoryCacheInterface
+    factory: memory_cache.factory
+    arguments: ['entity']
+
   entity_type.manager:
     class: Drupal\Core\Entity\EntityTypeManager
     arguments: ['@container.namespaces', '@module_handler', '@cache.discovery', '@string_translation', '@class_resolver', '@entity.last_installed_schema.repository']
diff --git a/core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactory.php b/core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactory.php
new file mode 100644
index 0000000000..cfbc87e7c7
--- /dev/null
+++ b/core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactory.php
@@ -0,0 +1,31 @@
+<?php
+
+
+namespace Drupal\Core\Cache\MemoryCache;
+
+/**
+ * Provides the default implementation of 'memory_cache.factory' service.
+ */
+class MemoryCacheFactory implements MemoryCacheFactoryInterface {
+
+  /**
+   * A list of cache bin instances keyed by cache bin name.
+   *
+   * @var \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface[]
+   */
+  protected $bins = [];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function get($bin) {
+    assert(!empty($bin) && is_string($bin), 'The $bin argument should be a non-empty string.');
+
+    if (!isset($this->bins[$bin])) {
+      $this->bins[$bin] = new MemoryCache();
+    }
+
+    return $this->bins[$bin];
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactoryInterface.php b/core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactoryInterface.php
new file mode 100644
index 0000000000..79801d6e62
--- /dev/null
+++ b/core/lib/Drupal/Core/Cache/MemoryCache/MemoryCacheFactoryInterface.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Drupal\Core\Cache\MemoryCache;
+
+/**
+ * Provides a contract for the 'memory_cache.factory' service.
+ */
+interface MemoryCacheFactoryInterface {
+
+  /**
+   * Creates a new memory cache bin instance.
+   *
+   * @param string $bin
+   *    The cache bin for which a cache backend object should be returned.
+   *
+   * @return \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface
+   *   The memory cache backend object associated with the specified bin.
+   */
+  public function get($bin);
+
+}
diff --git a/core/modules/jsonapi/jsonapi.services.yml b/core/modules/jsonapi/jsonapi.services.yml
index 16c7f4dc95..8a4c8feb3c 100644
--- a/core/modules/jsonapi/jsonapi.services.yml
+++ b/core/modules/jsonapi/jsonapi.services.yml
@@ -114,7 +114,9 @@ services:
 
   # Cache.
   cache.jsonapi_resource_types:
-    class: Drupal\Core\Cache\MemoryCache\MemoryCache
+    class: Drupal\Core\Cache\MemoryCache\MemoryCacheInterface
+    factory: memory_cache.factory
+    arguments: ['jsonapi']
     # We need this to add this to the Drupal's cache_tags.invalidator service.
     # This way it can invalidate the data in here based on tags.
     tags: [{ name: cache.bin }]
