public async Task StoreValidationResultCache(string pubKey, string keyId, string secret) { var next3Minutes = new DateTimeOffset(DateTime.Now.AddMonths(3)); var options = new DistributedCacheEntryOptions().SetAbsoluteExpiration(next3Minutes); var value = new KeySecretValidationResultCacheItem(pubKey, keyId).ToBytes(); // Store validation result await _cache.SetAsync(secret, value, options); }
public bool IsValidOnCache(string pubkey, string secret, out string keyId) { keyId = ""; var value = _cache.Get(pubkey); if (value != null) { var pubKeyOnCache = new KeySecretValidationResultCacheItem(value); keyId = pubKeyOnCache.KeyId; return(pubkey == pubKeyOnCache.PubKey); } return(false); }