Skip to content

Commit 1a87d7d

Browse files
author
catch
committed
Issue #3498154 by alexpott, catch, kristiaanvandeneynde: Use LRU Cache for static entity cache
1 parent dc48235 commit 1a87d7d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

assets/scaffold/files/default.services.yml

+5
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ parameters:
238238
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
239239
supportsCredentials: false
240240

241+
# The maximum number of entities stored in memory. Lowering this number can
242+
# reduce the amount of memory used in long-running processes like migrations,
243+
# however will also increase requests to the database or entity cache backend.
244+
entity.memory_cache.slots: 1000
245+
241246
queue.config:
242247
# The maximum number of seconds to wait if a queue is temporarily suspended.
243248
# This is not applicable when a queue is suspended but does not specify

core.services.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ parameters:
88
# function properly before that runs.
99
cache_default_bin_backends: []
1010
memory_cache_default_bin_backends: []
11+
entity.memory_cache.slots: 1000
1112
security.enable_super_user: true
1213
core.moved_classes:
1314
'Drupal\Core\StringTranslation\TranslationWrapper':
@@ -705,8 +706,8 @@ services:
705706
arguments: ['@theme_handler', '@config.factory', '@config.installer', '@module_handler', '@config.manager', '@asset.css.collection_optimizer', '@router.builder', '@logger.channel.default', '@state', '@extension.list.module', '@theme.registry', '@extension.list.theme']
706707
Drupal\Core\Extension\ThemeInstallerInterface: '@theme_installer'
707708
entity.memory_cache:
708-
class: Drupal\Core\Cache\MemoryCache\MemoryCache
709-
arguments: ['@datetime.time']
709+
class: Drupal\Core\Cache\MemoryCache\LruMemoryCache
710+
arguments: ['@datetime.time', '%entity.memory_cache.slots%']
710711
Drupal\Core\Cache\MemoryCache\MemoryCacheInterface: '@entity.memory_cache'
711712
entity_type.manager:
712713
class: Drupal\Core\Entity\EntityTypeManager

modules/migrate/src/MigrateExecutable.php

-3
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,6 @@ protected function attemptMemoryReclaim() {
612612
// plenty of memory to continue.
613613
drupal_static_reset();
614614

615-
// Entity storage can blow up with caches, so clear it out.
616-
\Drupal::service('entity.memory_cache')->deleteAll();
617-
618615
// @todo Explore resetting the container.
619616

620617
// Run garbage collector to further reduce memory.

0 commit comments

Comments
 (0)