Unverified Commit 69c9b19a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3047289 by catch, mxr576, yogeshmpawar, hardik_patel_12, jweowu,...

Issue #3047289 by catch, mxr576, yogeshmpawar, hardik_patel_12, jweowu, donquixote, kristiaanvandeneynde, kim.pepper, claudiu.cristea, Ratan Priya, berdir, nicxvan, alexpott: Standardize how we implement in-memory caches
parent 747a536e
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -52,5 +52,9 @@
%Drupal\\field\\Plugin\\migrate\\process\\ProcessField\(\) is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement.%
%Drupal\\field\\Plugin\\migrate\\process\\FieldType\(\) is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement.%

# Drupal 13.
%The "cache.backend.memory" service is deprecated in drupal:11.3.0 and is removed from drupal:13.0.0. Use cache.backend.memory.memory instead. See https://www.drupal.org/node/3546856%
%The "cache.static" service is deprecated in drupal:11.3.0 and is removed from drupal:13.0.0. Use the cache.memory bin instead. See https://www.drupal.org/node/3546856%

# Symfony 7.3.
%Since symfony/validator 7.3: Passing an array of options to configure the "[^"]+" constraint is deprecated, use named arguments instead.%
+12 −0
Original line number Diff line number Diff line
@@ -467,6 +467,9 @@
 *   - data: Contains data that can vary by path or similar context.
 *   - discovery: Contains cached discovery data for things such as plugins,
 *     views_data, or YAML discovered data such as library info.
 *   - memory: An in-memory cache bin, also called static cache. Useful
 *     alternative to properties when cache invalidation is needed, for example
 *     through cache tags.
 *
 * A module can define a cache bin by defining a service in its
 * modulename.services.yml file as follows (substituting the desired name for
@@ -479,6 +482,15 @@
 *   factory: ['@cache_factory', 'get']
 *   arguments: [name_of_bin]
 * @endcode
 *
 * The tag can also include a default backend, which is useful for example
 * when defining in-memory (which uses a separate tag) or fast chained bin.
 *
 * @code
 * - { name: cache.bin, default_backend: cache.backend.chainedfast }
 * - { name: cache.bin.memory, default_backend: cache.backend.memory.memory }
 * @endcode
 *
 * See the @link container Services topic @endlink for more on defining
 * services.
 *
+13 −7
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ services:
  cache.backend.memory:
    class: Drupal\Core\Cache\MemoryBackendFactory
    arguments: ['@datetime.time']
    deprecated: 'The "%service_id%" service is deprecated in drupal:11.3.0 and is removed from drupal:13.0.0. Use cache.backend.memory.memory instead. See https://www.drupal.org/node/3546856'
  cache.backend.memory.memory:
    class: Drupal\Core\Cache\MemoryCache\MemoryCacheFactory
    arguments: ['@datetime.time']
@@ -271,6 +272,7 @@ services:
    class: Drupal\Core\Cache\CacheBackendInterface
    tags:
      - { name: cache.bin, default_backend: cache.backend.memory }
    deprecated: 'The "%service_id%" service is deprecated in drupal:11.3.0 and is removed from drupal:13.0.0. Use the cache.memory bin instead. See https://www.drupal.org/node/3546856'
    factory: ['@cache_factory', 'get']
    arguments: [static]
  cache.bootstrap:
@@ -333,6 +335,12 @@ services:
      - { name: cache.bin, default_backend: cache.backend.chainedfast }
    factory: ['@cache_factory', 'get']
    arguments: [discovery]
  cache.memory:
    class: Drupal\Core\Cache\MemoryCache\MemoryCacheInterface
    tags:
      - { name: cache.bin.memory, default_backend: cache.backend.memory.memory }
    factory: ['@cache_factory', 'get']
    arguments: [memory]
  cache_prewarmer:
    class: Drupal\Core\PreWarm\CachePreWarmer
    arguments: ['@class_resolver']
@@ -725,7 +733,9 @@ services:
  entity.memory_cache:
    class: Drupal\Core\Cache\MemoryCache\LruMemoryCache
    arguments: ['@datetime.time', '%entity.memory_cache.slots%']
  Drupal\Core\Cache\MemoryCache\MemoryCacheInterface: '@entity.memory_cache'
  Drupal\Core\Cache\MemoryCache\MemoryCacheInterface:
    alias: 'entity.memory_cache'
    deprecated: 'The "%alias_id%" service is deprecated in drupal:11.3.0 and is removed from drupal:13.0.0. Use #Autowire to pick a specific cache bin, such as cache.memory. See https://www.drupal.org/node/3546856'
  entity_type.manager:
    class: Drupal\Core\Entity\EntityTypeManager
    arguments: ['@container.namespaces', '@module_handler', '@cache.discovery', '@string_translation', '@class_resolver', '@entity.last_installed_schema.repository', '@service_container']
@@ -1644,7 +1654,7 @@ services:
  Drupal\Core\Session\PermissionCheckerInterface: '@permission_checker'
  user_permissions_hash_generator:
    class: Drupal\Core\Session\PermissionsHashGenerator
    arguments: ['@private_key', '@cache.static', '@access_policy_processor']
    arguments: ['@private_key', '@cache.memory', '@access_policy_processor']
  Drupal\Core\Session\PermissionsHashGeneratorInterface: '@user_permissions_hash_generator'
  current_user:
    class: Drupal\Core\Session\AccountProxy
@@ -1748,15 +1758,11 @@ services:
  Drupal\Core\Asset\LibraryDependencyResolverInterface: '@library.dependency_resolver'
  # Set up a cache chain for asset caching as the same assets may be
  # requested several times, non-public as they are not meant to be reused.
  cache.asset_memory:
    class: Drupal\Core\Cache\MemoryCache\MemoryCache
    arguments: ['@datetime.time']
    public: false
  cache.asset_chain:
    class: Drupal\Core\Cache\BackendChain
    public: false
    calls:
      - [ appendBackend, [ '@cache.asset_memory' ] ]
      - [ appendBackend, [ '@cache.memory' ] ]
      - [ appendBackend, [ '@cache.data' ] ]
  asset.resolver:
    class: Drupal\Core\Asset\AssetResolver
+0 −6
Original line number Diff line number Diff line
@@ -8,9 +8,3 @@ services:
  field.uninstall_validator:
    class: Drupal\field\FieldUninstallValidator
    arguments: ['@entity_type.manager', '@string_translation', '@plugin.manager.field.field_type']
  cache.field_config_memory:
    class: Drupal\Core\Cache\CacheBackendInterface
    tags:
      - { name: cache.bin.memory, default_backend: cache.backend.memory.memory }
    factory: ['@cache_factory', 'get']
    arguments: [field_config_memory]
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class FieldHooks {
  use StringTranslationTrait;

  public function __construct(
    #[Autowire(service: 'cache.field_config_memory')]
    #[Autowire(service: 'cache.memory')]
    protected readonly CacheBackendInterface $memoryCache,
  ) {

Loading