Flatwhite.Hot.DisposingPhoenix.Reborn C# (CSharp) Method

Reborn() public method

Do nothing here as the disposing action has been started
public Reborn ( Func rebornAction ) : IPhoenixState
rebornAction Func
return IPhoenixState
        public IPhoenixState Reborn(Func<Task<IPhoenixState>> rebornAction)
        {
            return this;
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Rebuild the cache and return the new <see cref="IPhoenixState"/>
        /// </summary>
        /// <returns></returns>
        protected virtual async Task <IPhoenixState> FireAsync()
        {
            MethodInfo.CheckMethodForCacheSupported(out _isAsync);

            try
            {
                var target        = GetTargetInstance();
                var invokedResult = await InvokeAndGetBareResult(target).ConfigureAwait(false);

                var cacheItem = GetCacheItem(invokedResult);
                if (cacheItem == null)
                {
                    var disposing = new DisposingPhoenix(DieAsync());
                    return(disposing.Reborn(null));
                }

                var cacheStore = Global.CacheStoreProvider.GetAsyncCacheStore(_info.StoreId);
                //NOTE: Because the cacheItem was created before, the cacheStore cannot be null
                await cacheStore.SetAsync(_info.Key, cacheItem, DateTime.UtcNow.AddSeconds(_info.MaxAge + _info.StaleWhileRevalidate)).ConfigureAwait(false);

                Global.Logger.Info($"Updated key \"{_info.Key}\", store \"{_info.StoreId}\"");

                Retry(_info.GetRefreshTime());
                _phoenixState = new InActivePhoenix();
                return(_phoenixState);
            }
            catch (Exception ex)
            {
                Global.Logger.Error($"Error while refreshing key {_info.Key}, store \"{_info.StoreId}\". Will retry after 1 second.", ex);
                Retry(TimeSpan.FromSeconds(1));
                throw;
            }
        }
All Usage Examples Of Flatwhite.Hot.DisposingPhoenix::Reborn