[11.x] Configuration to disable events on Cache Repository #51032
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.
This change allows caches to be defined without auto-registering events dispatcher.
On in-memory caches like array or apc, the overhead of triggering events results in an 80%+ overhead for basic cache operations. This change allows a config value on any cache definition to disable events for that particular Repository.
Benefit:
In some circumstances it is helpful to use an in-memory cache like array or apc, however in operations that use a lot of cache calls the overhead starts to dramatically impact performance. Being able to define a cache without events allows for the conveniences of the caching API while minimizing the overhead to the API implementation and not the events side-effects.
Usage:
Adding
'with_events' => false
to any cache stores configuration will prevent the automatic registration of the events dispatcher. For example, the following changes the 'array' store to not register events:Backwards Compatibility Concerns:
I've implemented this new setting to default to true when the setting isn't defined on the config, so it has no backwards compatibility concerns.
Tests:
Added test for CacheManager to handle this new setting and test the previous functionality where no setting is provided.