/// <summary>
        ///     Create a Resilient Cache.
        /// </summary>
        /// <param name="cache">
        ///     A <see cref="IBrowsingCache" /> to proxy to.
        /// </param>
        /// <param name="retryAttempts">
        ///     The number of attempts a failed operation should be retried.
        /// </param>
        /// <param name="ownCache">
        ///     A boolean flag indicating whether or not the resilient cache takes ownership of
        ///     <paramref name="cache" /> and disposes it when the resilient cache itself is disposed. If the resilient
        ///     cache takes ownership of <paramref name="cache" /> and you reference or dispose
        ///     <paramref name="cache" /> after you create the resilient cache, the behavior of the resilient cache and
        ///     <paramref name="cache" /> is undefined.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        ///     Thrown if <paramref name="cache" /> is a null reference.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        ///     Thrown if <paramref name="retryAttempts" /> is less than or equal to <c>0</c>.
        /// </exception>
        public ResilientBrowsingCache(IBrowsingCache cache, int retryAttempts, bool ownCache)
        {
            Guard.ThrowIf(nameof(retryAttempts), retryAttempts).LessThanOrEqualTo(0);

            this._cache         = BrowsingCacheProxy.Create(cache, ownCache);
            this._disposed      = false;
            this._ownCache      = ownCache;
            this._retryAttempts = retryAttempts;
            // ...
            //
            // ...
            this._resiliencyPolicy = CreateResiliencyPolicy(this);

            // <summary>
            //      Create Resiliency Policy.
            // </summary>
            IAsyncPolicy CreateResiliencyPolicy(ResilientBrowsingCache @this)
            {
                var cPolicyBuilder = Policy.Handle <BrowsingCacheException>();
                var cPolicy        = cPolicyBuilder.WaitAndRetryAsync(@this._retryAttempts, CreateRetryPolicyTimeout);

                return(cPolicy);
            }

            // <summary>
            //      Create Retry Policy Timeout.
            // </summary>
            TimeSpan CreateRetryPolicyTimeout(int cRetryAttempt)
            {
                var cDelaySeconds = Math.Pow(2, cRetryAttempt);
                var cDelay        = TimeSpan.FromSeconds(cDelaySeconds);

                return(cDelay);
            }
        }
 /// <summary>
 ///     Create a Cache Proxy.
 /// </summary>
 /// <param name="cache">
 ///     A <see cref="IBrowsingCache" /> to proxy to. The cache proxy takes ownership of
 ///     <paramref name="cache" /> and will dispose it when the cache proxy itself is disposed. If you reference
 ///     or dispose <paramref name="cache" /> after you create the cache proxy, the behavior of the cache proxy
 ///     and <paramref name="cache" /> is undefined.
 /// </param>
 /// <returns>
 ///     A cache proxy.
 /// </returns>
 /// <exception cref="System.ArgumentNullException">
 ///     Thrown if <paramref name="cache" /> is a null reference.
 /// </exception>
 internal static BrowsingCacheProxy Create(IBrowsingCache cache) => BrowsingCacheProxy.Create(cache, true);