mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 02:23:05 +00:00
AccountService: Cache token data (#6260)
* 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
This commit is contained in:
parent
a37e2d6e44
commit
d56bab1e24
1 changed files with 10 additions and 1 deletions
|
@ -22,6 +22,9 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||||
private readonly UserId _userId;
|
private readonly UserId _userId;
|
||||||
#pragma warning restore IDE0052
|
#pragma warning restore IDE0052
|
||||||
|
|
||||||
|
private byte[] _cachedTokenData;
|
||||||
|
private DateTime _cachedTokenExpiry;
|
||||||
|
|
||||||
public ManagerServer(UserId userId)
|
public ManagerServer(UserId userId)
|
||||||
{
|
{
|
||||||
_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.Memory.Write(bufferPosition, tokenData);
|
||||||
context.ResponseData.Write(tokenData.Length);
|
context.ResponseData.Write(tokenData.Length);
|
||||||
|
|
Loading…
Reference in a new issue