예제 #1
0
        public void RefreshData()
        {
            try
            {
                if (string.IsNullOrEmpty(_secretManager.Secrets.GoogleApiKey))
                {
                    return;
                }

                if (DateTime.Now.Subtract(_lastAccessed).Minutes < 30)
                {
                    return;
                }

                _lastAccessed = DateTime.Now;

                var data = _httpWrapper.GetData(
                    string.Format(API_URL, _secretManager.Secrets.GoogleApiKey),
                    ResponseBuilder);
                _cache.Add(CACHE_KEY, data,
                           new MemoryCacheEntryOptions()
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
                });
                _fileSystemWrapper.SaveFile(FILE_CACHE_PATH, JsonConvert.SerializeObject(data));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error thrown getting data from YouTube");
            }
        }
 public void RefreshData()
 {
     try
     {
         var data = _httpWrapper.GetData(API_URL, ResponseBuilder);
         _cache.Add(CACHE_KEY, data,
                    new MemoryCacheEntryOptions()
         {
             AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(1)
         });
         _fileSystemWrapper.SaveFile(FILE_CACHE_PATH, JsonConvert.SerializeObject(data));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error thrown getting data from Meetup");
     }
 }