示例#1
0
        public async Task <TeamCloudInstance> GetAsync(bool refresh)
        {
            var container = await GetContainerAsync()
                            .ConfigureAwait(false);

            ContainerDocumentCacheEntry <TeamCloudInstance> cacheEntry = null;

            if (cache != null && !refresh)
            {
                var created = false;

                cacheEntry = await cache
                             .GetOrCreateAsync(nameof(TeamCloudInstance), (key) => { created = true; return(FetchAsync()); })
                             .ConfigureAwait(false);

                if (!created && cache.InMemory)
                {
                    var cacheEntryCurrent = await FetchAsync(cacheEntry.ETag)
                                            .ConfigureAwait(false);

                    return((cacheEntryCurrent ?? cacheEntry)?.Value);
                }
            }

            return((cacheEntry ?? await FetchAsync().ConfigureAwait(false))?.Value);

            async Task <ContainerDocumentCacheEntry <TeamCloudInstance> > FetchAsync(string currentETag = default)
示例#2
0
 Task <ContainerDocumentCacheEntry <T> > IContainerDocumentCache.SetAsync <T>(string key, ContainerDocumentCacheEntry <T> value, ContainerDocumentCacheEntryOptions options, CancellationToken token)
 => Task.FromResult(value);