Exemple #1
0
        /// <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();
            }
        }
Exemple #3
0
        /// <inheritdoc />
        public bool TryExpireToken()
        {
            IExpiryStashContracts.TryExpireToken(this);

            ExpiryToken <TKey> token;

            while (this.tokens.TryTake(out token))
            {
                if (token.TryDisposeCacheValue())
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #4
0
        /// <inheritdoc />
        public bool TryExpireToken()
        {
            IExpiryStashContracts.TryExpireToken(this);

            return(false);
        }
Exemple #5
0
        /// <inheritdoc />
        public void AddExpiration(ExpiryToken <TKey> expiration)
        {
            IExpiryStashContracts.AddExpiration(this);

            expiration.TryDisposeCacheValue();
        }