private static bool LoadCache(this LightDBMapper mapper) { string cacheFilename = mapper.GetCacheFilename(); if (mapper.IsCached()) { try { if (mapper.LoadCache(cacheFilename)) { return(true); } ContentMgr.log.Warn("Cache signature in file \"{0}\" is out of date.", cacheFilename); ContentMgr.log.Warn("Reloading content from Database..."); } catch (Exception ex) { if (ex is EndOfStreamException) { ContentMgr.log.Warn("Cache signature in file \"{0}\" is out of date.", cacheFilename); } else { LogUtil.ErrorException(ex, "Unable to load cache from \"" + cacheFilename + "\".", new object[0]); } ContentMgr.log.Warn("Reloading content from Database..."); } } return(false); }
private static bool LoadCache(this LightDBMapper mapper) { var file = GetCacheFilename(mapper); if (mapper.IsCached()) { try { // Utility.Measure("Loading contnt from Cache - " + mapper, 1, () => { if (mapper.LoadCache(file)) { // loaded cache successfully return(true); } log.Warn("Cache signature in file \"{0}\" is out of date.", file); log.Warn("Reloading content from Database..."); //}); //return; } catch (Exception ex) { if (ex is EndOfStreamException) { log.Warn("Cache signature in file \"{0}\" is out of date.", file); } else { LogUtil.ErrorException(ex, "Unable to load cache from \"" + file + "\"."); } log.Warn("Reloading content from Database..."); } } return(false); }
/// <summary> /// Ensures that the DataHolder of the given type and those that are connected with it, are loaded. /// /// </summary> /// <param name="force">Whether to re-load if already loaded.</param> public static bool Load <T>(bool force) where T : IDataHolder { ContentMgr.EnsureInitialized(); LightDBMapper mapper = ContentMgr.GetMapper <T>(); if (!force && mapper.Fetched) { return(false); } if (force && mapper.IsCached()) { mapper.FlushCache(); } ContentMgr.Load(mapper); return(true); }