Esempio n. 1
0
        public async Task <CacheResponse> IsCacheOutOfDate(DateTime cacheLastUpdatedTimeUtc, int appId, CancellationToken token)
        {
            var endpoint = configurationProvider.GetConnectionStringById(connectionStringKey);

            endpoint += $"?appId={appId}";

            var gatewayResponse = await webGateway.GetResponseFromEndpoint <ResponseDao>(endpoint, token);

            if (gatewayResponse.ResultCode != WebRequestResponseResultCode.Succeeded)
            {
                return(CacheResponse.CacheCheckFailed(gatewayResponse.ResultMessage));
            }

            var response = gatewayResponse.Value;

            if (!response.IsCached)
            {
                return(CacheResponse.OutOfDate());
            }

            if (response.CachedDateTimeUtc < cacheLastUpdatedTimeUtc)
            {
                return(CacheResponse.NotOutOfDate());
            }

            return(CacheResponse.OutOfDate());
        }
Esempio n. 2
0
        public async Task <CacheResponse> IsCacheOutOfDate(DateTime cacheLastUpdatedTimeUtc, CancellationToken token)
        {
            var endpoint = configurationProvider.GetConnectionStringById(connectionStringKey);

            var gatewayResponse = await webGateway.GetResponseFromEndpoint <ResponseDao>(endpoint, token);

            if (!gatewayResponse.Succeeded)
            {
                return(CacheResponse.OutOfDate());
            }

            var response = gatewayResponse.Value;

            if (!response.IsCached)
            {
                return(CacheResponse.OutOfDate());
            }

            if (response.CachedDateTimeUtc < cacheLastUpdatedTimeUtc)
            {
                return(CacheResponse.NotOutOfDate());
            }

            return(CacheResponse.OutOfDate());
        }