Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static void FlushCache(this LightDBMapper mapper)
        {
            string cacheFilename = mapper.GetCacheFilename();

            if (!File.Exists(cacheFilename))
            {
                return;
            }
            File.Delete(cacheFilename);
        }
Ejemplo n.º 3
0
        public static void SaveCache(this LightDBMapper mapper)
        {
            string cacheFilename = mapper.GetCacheFilename();

            try
            {
                mapper.SaveCache(cacheFilename);
            }
            catch (Exception ex)
            {
                File.Delete(cacheFilename);
                LogUtil.ErrorException(ex, "Failed to save cache to file: " + cacheFilename, new object[0]);
            }
        }
Ejemplo n.º 4
0
 public static bool IsCached(this LightDBMapper mapper)
 {
     return(File.Exists(mapper.GetCacheFilename()));
 }