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); }
public static void Load(LightDBMapper mapper, bool failException) { try { if (ContentMgr.EnableCaching && mapper.SupportsCaching && mapper.LoadCache()) { return; } mapper.Fetch(); if (!ContentMgr.EnableCaching || !mapper.SupportsCaching) { return; } ContentMgr.log.Info("Saving cache for: " + ((IEnumerable <DataHolderDefinition>)mapper.Mapping.DataHolderDefinitions) .ToString <DataHolderDefinition>(", ")); mapper.SaveCache(); } catch (Exception ex) { if (failException) { throw new ContentException(ex, "Unable to load entries using \"{0}\"", new object[1] { (object)mapper }); } } }
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); }
public static void Load(LightDBMapper mapper, bool failException) { try { if (EnableCaching && mapper.SupportsCaching && mapper.LoadCache()) { return; } mapper.Fetch(); if (!EnableCaching || !mapper.SupportsCaching) { return; } log.Info("Saving cache for: " + mapper.Mapping.DataHolderDefinitions .ToString(", ")); mapper.SaveCache(); } catch (Exception ex) { if (failException) { throw new ContentException(ex, "Unable to load entries using \"{0}\"", (object)mapper); } } }
public static void Load(LightDBMapper mapper, bool failException) { try { if (EnableCaching && mapper.SupportsCaching) { if (mapper.LoadCache()) { // loaded cache successfully return; } } //Utility.Measure("Loading content from DB - " + mapper + "", 1, () => { mapper.Fetch(); //}); if (EnableCaching && mapper.SupportsCaching) { log.Info("Saving cache for: " + mapper.Mapping.DataHolderDefinitions.ToString(", ")); mapper.SaveCache(); } } catch (Exception e) { if (failException) { throw new ContentException(e, "Unable to load entries using \"{0}\"", mapper); } // LogUtil.ErrorException(e, "Unable to load entries using \"{0}\"", mapper); } }