Commit f3b3520
authored
Start caching certain level and user attributes (#1047)
This PR adds a `CacheService`, which temporarily caches `GameAsset`s
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.42 files changed
Lines changed: 665 additions & 69 deletions
File tree
- Refresh.Common
- Refresh.Core
- Extensions
- Services
- Types
- Cache
- Data
- Relations
- Refresh.Database
- Models/Levels
- Refresh.GameServer
- Refresh.Interfaces.APIv3
- Endpoints
- Admin
- DataTypes/Response
- Levels
- Users
- Extensions
- Refresh.Interfaces.Game
- Endpoints
- DataTypes/Response
- Handshake
- Levels
- Types
- Levels
- Playlists
- UserData
- RefreshTests.GameServer
- GameServer
- Tests/Matching
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
| |||
172 | 176 | | |
173 | 177 | | |
174 | 178 | | |
175 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
176 | 184 | | |
177 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
178 | 190 | | |
179 | 191 | | |
180 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments