Fix perf with cache

This commit is contained in:
2025-10-10 03:42:57 +07:00
parent bdda24cb60
commit b6b11be33a
13 changed files with 1646 additions and 32 deletions

View File

@@ -144,12 +144,8 @@ public class UserService : IUserService
// Fetch from database (either cache miss or cache disabled)
var account = await _accountService.GetAccountByKey(address, true, false);
var user = await _userRepository.GetUserByNameAsync(account.User.Name);
var user = await _userRepository.GetUserByNameAsync(account.User.Name, true);
// Use proper async version to avoid DbContext concurrency issues
user.Accounts = (await _accountService.GetAccountsByUserAsync(user)).ToList();
// Save to cache for 5 minutes if caching is enabled (JWT middleware calls this on every request)
if (useCache)
{
_cacheService.SaveValue(cacheKey, user, TimeSpan.FromMinutes(5));