public bool TryGetValue(string credentialSpec, out SecretCredential secret) { if (this.secretCache.TryGetValue(credentialSpec, out var cachedValue)) { var now = this.clock.Get(); if (now < cachedValue.Expiry - TimeSpan.FromMinutes(5)) { this.logger.LogInformation($"Found cached token for {credentialSpec}, expires after {cachedValue.Expiry}"); secret = cachedValue; return(true); } else { this.logger.LogInformation($"Found cached token for {credentialSpec}, but expired already or near it ({cachedValue.Expiry})"); secret = SecretCredential.Empty; return(false); } } secret = SecretCredential.Empty; return(false); }
public void TryAdd(string credentialSpec, SecretCredential newVal) { this.secretCache.AddOrUpdate(credentialSpec, newVal, (_, _) => newVal); }
public HomeController(SecretCredential credential) { this.credential = credential; }