Skip to content

Start caching certain level and user attributes#1047

Merged
Toastbrot236 merged 15 commits intoLittleBigRefresh:mainfrom
Toastbrot236:level-opt
Mar 12, 2026
Merged

Start caching certain level and user attributes#1047
Toastbrot236 merged 15 commits intoLittleBigRefresh:mainfrom
Toastbrot236:level-opt

Conversation

@Toastbrot236
Copy link
Contributor

This PR adds a CacheService, which temporarily caches GameAssets 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 the CacheService first 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 a Thread, 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.

@Toastbrot236 Toastbrot236 merged commit f3b3520 into LittleBigRefresh:main Mar 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant