-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Move cache instructions pruning to background job #19598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Move cache instructions pruning to background job #19598
Conversation
There was a problem hiding this comment.
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 extracts cache instruction pruning from the CacheInstructionService
and shifts it into a dedicated CacheInstructionsPruningJob
, cleaning up obsolete methods and constructors and updating registrations and tests accordingly.
- Introduces
CacheInstructionsPruningJob
and registers it as a recurring background job. - Removes pruning logic and related overloads from
CacheInstructionService
andDatabaseServerMessenger
. - Updates unit and integration tests to call the new
ProcessInstructions
overload and remove assertions around pruning.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/.../CacheInstructionsPruningJobTests.cs | Adds unit tests for the new pruning job’s period and run logic |
tests/.../CacheInstructionServiceTests.cs (Integration) | Updates calls to ProcessInstructions and removes pruning tests |
src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs | Registers CacheInstructionsPruningJob |
src/Umbraco.Infrastructure/Sync/DatabaseServerMessenger.cs | Removes server-role–based pruning and obsolete fields |
src/Umbraco.Infrastructure/Sync/BatchedDatabaseServerMessenger.cs | Adds new constructor, marks old one obsolete |
src/Umbraco.Infrastructure/Services/CacheInstructionService.cs | Removes inline pruning logic and obsolete overload |
src/Umbraco.Infrastructure/BackgroundJobs/Jobs/CacheInstructionsPruningJob.cs | Adds the new background job implementation |
src/Umbraco.Core/Services/ProcessInstructionsResult.cs | Marks pruning flag and related factory as obsolete |
src/Umbraco.Core/Services/ICacheInstructionService.cs | Adds new overload for ProcessInstructions |
Comments suppressed due to low confidence (2)
src/Umbraco.Core/Services/ICacheInstructionService.cs:37
- The summary for the new
ProcessInstructions
overload still mentions pruning, but pruning now happens in a background job. Update the XML comment to reflect that this overload only processes instructions.
/// Processes and then prunes pending database cache instructions.
src/Umbraco.Infrastructure/Sync/BatchedDatabaseServerMessenger.cs:54
- The obsolete constructor takes an
IRequestAccessor requestAccessor
but callsthis(..., requestCache, ...)
. TherequestCache
parameter isn't in scope and will not compile. IncludeIRequestCache requestCache
in the obsolete signature or pass the correct parameter.
public BatchedDatabaseServerMessenger(
Description
Moves the cache instructions pruning from the
CacheInstructionService.ProcessInstructions()
method to a newCacheInstructionsPruningJob
background job.Testing
Make sure that the instructions are still pruned as expected, by checking the
umbracoCacheInstruction
database table.To help with testing, adjust the following app settings to lower values:
This should make it so that the job will run every 30 seconds, and will delete all instructions older than 5 minutes (always leaving at least 1).
Be aware that there is a default delay of 3 minutes (default) from startup to when the background job actually starts running.