Start caching certain level and user attributes#1047
Merged
Toastbrot236 merged 15 commits intoLittleBigRefresh:mainfrom Mar 12, 2026
Merged
Start caching certain level and user attributes#1047Toastbrot236 merged 15 commits intoLittleBigRefresh:mainfrom
Toastbrot236 merged 15 commits intoLittleBigRefresh:mainfrom
Conversation
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.
This PR adds a
CacheService, which temporarily cachesGameAssets requested, aswell as level-user relations, user-user-relations, levels' skill rewards and tags in-memory. This way, various level and user attributes, which otherwise require extra DB queries per level/user during serialization, will be looked up in theCacheServicefirst before falling back to looking them up in the database. They will be requested from DB the first time, added to cache, and then taken from there for all other requests in the near future. This results in various level/user related API requests, like level lists and especially photo lists, being way faster (for me, requesting a list of 23 photos was reduced from ~110ms to ~50ms).Cached data, which is deemed "expired", will be refetched from DB the next time it's requested from the
CacheService. Alternatively, it will be removed from cache by aThread, which automatically removes all expired data from the service every few minutes, to prevent unused data from staying there potentially indefinitely.Certain actions, like e.g. hearting a level, will also update the cache (alongside DB) to reflect that change.