Skip to content

Instance cache - #351

Merged
krystian-panek-vmltech merged 2 commits into
mainfrom
instance-status-caching
Jul 29, 2026
Merged

Instance cache#351
krystian-panek-vmltech merged 2 commits into
mainfrom
instance-status-caching

Conversation

@krystian-panek-vmltech

Copy link
Copy Markdown
Contributor

fixes #350, #349

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an in-memory, per-Instance cache to avoid repeated HTTP requests for status-derived values that are effectively constant while an AEM instance is running (notably system properties and derived values like timezone), addressing the /system/console/status-System%20Properties.json request storm described in #349/#350.

Changes:

  • Added InstanceCache with a config flag (instance.cache.enabled, default true) and unit tests, plus template YAML updates to expose the setting.
  • Updated Status methods to use InstanceCacheGet for SystemProps, SlingProps, SlingSettings, and AemVersion (while avoiding caching the “unknown during startup” case).
  • Reduced per-event timezone resolution cost in EventStableChecker and ensured cache invalidation on local instance start/stop.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/status.go Uses InstanceCacheGet to cache status-derived values and fixes TimeLocation() error propagation.
pkg/instance_cache.go Introduces the per-instance in-memory cache and generic cached-loader helper.
pkg/instance_cache_test.go Adds unit tests validating caching, non-caching of errors, clearing, and concurrent access.
pkg/instance.go Adds cache *InstanceCache to Instance and exposes it via Cache().
pkg/instance_manager.go Initializes the instance cache during instance construction.
pkg/local_instance.go Clears the instance cache after local start/stop to avoid stale cached values across lifecycle changes.
pkg/check.go Avoids per-event timezone resolution by reusing the location from instance.Now().
pkg/cfg/defaults.go Defaults instance.cache.enabled to true.
aem/default/etc/aem.yml Documents/enables instance cache in the default project template config.
examples/docker/src/aem/default/etc/aem.yml Documents/enables instance cache in the docker example template config.
pkg/project/instance/aem/default/etc/aem.yml Documents/enables instance cache in the instance project template config.
pkg/project/app_cloud/aem/default/etc/aem.yml Documents/enables instance cache in the app_cloud template config.
pkg/project/app_classic/aem/default/etc/aem.yml Documents/enables instance cache in the app_classic template config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@krystian-panek-vmltech
krystian-panek-vmltech merged commit 054e5da into main Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants