diff options
author | riperiperi <rhy3756547@hotmail.com> | 2024-02-06 22:11:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-06 23:11:20 +0100 |
commit | d56bab1e24d3461a037005b67d64e9cd4fc2a0df (patch) | |
tree | 3403c821aa670d4d7074be891a28a656149364f5 /src | |
parent | a37e2d6e44c7f384f26062dea5599749c7c60623 (diff) |
AccountService: Cache token data (#6260)1.1.1162
* AccountService: Cache token data
This method appears to indicate that the token returned should be cached. I've made it so that it generates a token that lasts until its expiration time, and reuses it on subsequent calls.
* Private naming convention
Diffstat (limited to 'src')
-rw-r--r-- | src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs index ec7fa5c4..75bad0e3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs @@ -22,6 +22,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService private readonly UserId _userId; #pragma warning restore IDE0052 + private byte[] _cachedTokenData; + private DateTime _cachedTokenExpiry; + public ManagerServer(UserId userId) { _userId = userId; @@ -144,7 +147,13 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService } */ - byte[] tokenData = Encoding.ASCII.GetBytes(GenerateIdToken()); + if (_cachedTokenData == null || DateTime.UtcNow > _cachedTokenExpiry) + { + _cachedTokenExpiry = DateTime.UtcNow + TimeSpan.FromHours(3); + _cachedTokenData = Encoding.ASCII.GetBytes(GenerateIdToken()); + } + + byte[] tokenData = _cachedTokenData; context.Memory.Write(bufferPosition, tokenData); context.ResponseData.Write(tokenData.Length); |