Instance cache - #351
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
InstanceCachewith a config flag (instance.cache.enabled, defaulttrue) and unit tests, plus template YAML updates to expose the setting. - Updated
Statusmethods to useInstanceCacheGetforSystemProps,SlingProps,SlingSettings, andAemVersion(while avoiding caching the “unknown during startup” case). - Reduced per-event timezone resolution cost in
EventStableCheckerand 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #350, #349