Warm Patternkit Caches During Cache Rebuild

Created on 12 September 2023, about 1 year ago
Updated 25 September 2023, about 1 year ago

Problem/Motivation

For sites with a large collection of patterns, a cache clear could lead to performance and memory issues on the first page request to follow if it includes pattern usages since all patterns across all extensions and libraries have to be discovered and processed during the rendering process. To offset this, adding a hook to prepare those caches as part of the cache rebuild process could reduce the load on that first page request.

Steps to reproduce

  1. View a page with patternkit content displayed
  2. Observe existing cache entries for data in 'cache_discovery' database table:
    • 'patternkit.library_namespaces'
    • 'patternkit.patterns'
  3. Clear caches with drush: "drush cr"
  4. Observe patternkit entries are no longer present in 'cache_discovery' database table:
    • 'patternkit.library_namespaces'
    • 'patternkit.patterns'

Proposed resolution

Discover and cache library and pattern data during the cache rebuild process to remove this from the first page request.

Remaining tasks

User interface changes

None.

API changes

  • Added implementation of hook_rebuild() to trigger cache rebuilds.
  • Added new public 'rebuild()' method to 'patternkit.library.namespace_resolver' and 'patternkit.pattern.discovery' services to trigger cache rebuilds.

Data model changes

None.

Feature request
Status

Fixed

Version

9.1

Component

Module Core

Created by

🇺🇸United States slucero Arkansas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024