Enable caching capabilities on UserRepository #264
Merged
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 PR introduces caching capabilities on UserRepository as a demonstration of proposed implementation. I plan to do similarly on other repositories as well (but it will be a bit more complicated).
The intention is to enable implementor to configure 'Protocol Cache', which would then be used 'in front of' the regular database storage for protocol artifacts like tokens, and also for oidc clients and user data. Any Symfony cache adapter is supported. If the 'Protocol Cache' is not enabled or artifact is not cached, everything falls back to database.
If the implementor chooses to enable this, and enables some 'memory-capable' adapter, like memcache or similar, this should significantly improve performance, especially in cases like sudden surge of users when the database-only-storage becomes a noticable bootleneck.