public async Task RefreshNowAsync()

in src/Amazon.SecretsManager.Extensions.Caching/SecretCacheObject.cs [174:205]


        public async Task<bool> RefreshNowAsync(CancellationToken cancellationToken = default)
        {
            refreshNeeded = true;
            // When forcing a refresh, always sleep with a random jitter
            // to prevent coding errors that could be calling refreshNow
            // in a loop.
            long sleep = FORCE_REFRESH_JITTERED_DELAY.GetRetryDelay(1).Milliseconds;

            // Make sure we are not waiting for the next refresh after an
            // exception.  If we are, sleep based on the retry delay of
            // the refresh to prevent a hard loop in attempting to refresh a
            // secret that continues to throw an exception such as AccessDenied.
            if (null != exception)
            {
                long wait = nextRetryTime - Environment.TickCount;
                sleep = Math.Max(wait, sleep);
            }
            Thread.Sleep((int)sleep);

            // Perform the requested refresh.
            bool success = false;
            await Lock.WaitAsync(cancellationToken);
            try
            {
                success = await RefreshAsync(cancellationToken);
            }
            finally
            {
                Lock.Release();
            }
            return (null == exception && success);
        }