private void AutoUpdateCache(bool skipFirstUpdate = false, bool setOldCache = false) { log.Trace("Starting auto cache update"); while (true) { if (!skipFirstUpdate) { if (setOldCache) { log.Trace("Backup old cache"); OldCache = Cache.Copy(); } log.Trace("Updating cache"); CacheUpdating = true; Task.Run(() => UpdateCurrencyCache()).Wait(); // Task.Run(() => UpdateItemsCache()).Wait(); Cache.UpdateTime = DateTime.Now; CacheUpdating = false; SaveCache(); } else { log.Trace("Skipping first cache update"); Cache = OldCache.Copy(); } CacheReady = true; skipFirstUpdate = false; setOldCache = true; Thread.Sleep(CACHE_EXPIRATION_TIME_MINS * 60 * 1000); } }
private void LoadCache() { log.Trace("Loading cache"); OldCache = AppService.Instance.GetPoeNinjaCaches(); if (OldCache != null) { log.Trace("Existing cache found"); } }
public void SavePoeNinjaCaches(PoeNinjaCaches caches) { _appDataService.DeleteAllDocument(AppDataService.COLLECTION_POE_NINJA_CACHES); _appDataService.InsertDocument <PoeNinjaCaches>(AppDataService.COLLECTION_POE_NINJA_CACHES, caches); }