예제 #1
0
        public async Task FreshLoadToAsync(AsyncCacheData <TKey, TValue> data, CancellationToken token)
        {
            try
            {
                data.Clear();
                await LoadAsync(data, token).ConfigureAwait(false);

                token.ThrowIfCancellationRequested();
                await SerializeAsync(data).ConfigureAwait(false);
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception e)
            {
                if (Fallback == null)
                {
                    throw new AsyncCacheException(AsyncCacheErrorCode.InvalidCache, "Unknown Error", e);
                }
                await Fallback.FreshLoadToAsync(data, token).ConfigureAwait(false);
            }
        }