Exemplo n.º 1
0
        private async Task CacheLatestGameVersion()
        {
            if (!_cache.TryGetValue(CacheKeys.GameVersion, out var cacheEntry))
            {
                // Key not in cache, so get data.
                cacheEntry = await _versionProvider.GetLatestVersion();

                // Set cache options.
                var cacheEntryOptions = new MemoryCacheEntryOptions()
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(6)
                                                      // SlidingExpiration = TimeSpan.FromHours(12)
                };

                _logger.LogInformation($"Caching latest game version at '{cacheEntry}' for 6 hours");

                // Save data in cache.
                _cache.Set(CacheKeys.GameVersion, cacheEntry, cacheEntryOptions);
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public async Task ReportInfo()
        {
            var currentVersion = _versionProvider.GetCurrentVersion();
            var latestVersion  = await _versionProvider.GetLatestVersion();

            ReportEnvironmentalInfo(currentVersion);
            if (!latestVersion.Equals(currentVersion) && latestVersion.IsResolved)
            {
                ReportThatNewVersionIsAvailable(latestVersion);
            }
        }
Exemplo n.º 3
0
 /// <inheritdoc/>
 public async Task <VersionInfo> GetLatestVersion()
 {
     try
     {
         return(await _versionProvider.GetLatestVersion());
     }
     catch (Exception ex)
     {
         _logger.Error("Failed to retrieve information about the latest version", ex);
         return(VersionInfo.UnResolved);
     }
 }