Skip to content

Commit

Permalink
Expire token after entry expiration.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Oct 15, 2020
1 parent 5130935 commit 0c0ce21
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Server/API/AgentUpdateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ public async Task<ActionResult> DownloadPackage(string platform, string download
_downloadingAgents.TryGetValue(string.Empty, out _);
}

var expirationTimespan = TimeSpan.FromMinutes(10);
var entryExpirationTime = TimeSpan.FromMinutes(6);
var tokenExpirationTime = entryExpirationTime.Add(TimeSpan.FromSeconds(15));

var expirationToken = new CancellationChangeToken(
new CancellationTokenSource(expirationTimespan).Token);
new CancellationTokenSource(tokenExpirationTime).Token);

var cacheOptions = new MemoryCacheEntryOptions()
.SetAbsoluteExpiration(expirationTimespan)
.SetAbsoluteExpiration(entryExpirationTime)
.AddExpirationToken(expirationToken);

_downloadingAgents.Set(downloadId, string.Empty, cacheOptions);
Expand Down

0 comments on commit 0c0ce21

Please sign in to comment.