/// <inheritdoc /> public void AddExpiration(ExpiryToken <TKey> expiration) { IExpiryStashContracts.AddExpiration(this); while (!this.tokens.TryAdd(expiration)) { ExpiryToken <TKey> overflow; if (this.tokens.TryTake(out overflow)) { overflow.TryDisposeCacheValue(); } } }
/// <inheritdoc /> public void AddExpiration(ExpiryToken <TKey> expiration) { IExpiryStashContracts.AddExpiration(this); if (this.awaitingTokensCount.Read() <= 0) { // not awaiting a token so store it for disposal later this.stash.AddExpiration(expiration); } else { // pool is empty and Take/TakeAsync is awaiting a value so dispose token immediately expiration.TryDisposeCacheValue(); } }
/// <inheritdoc /> public bool TryExpireToken() { IExpiryStashContracts.TryExpireToken(this); ExpiryToken <TKey> token; while (this.tokens.TryTake(out token)) { if (token.TryDisposeCacheValue()) { return(true); } } return(false); }
/// <inheritdoc /> public bool TryExpireToken() { IExpiryStashContracts.TryExpireToken(this); return(false); }
/// <inheritdoc /> public void AddExpiration(ExpiryToken <TKey> expiration) { IExpiryStashContracts.AddExpiration(this); expiration.TryDisposeCacheValue(); }