//protected Dictionary<string, CacheHost> cacheIndex = null; public CacheService() { CacheConfig = CacheConfig.Load(); //db = new RaptorDB.RaptorDB<string>(CacheConfig.DBFile, false); cache = new Dictionary<string, CacheItem>(); //cacheIndex = new Dictionary<string, CacheHost>(); }
internal static CacheConfig Load() { CacheConfig cfg = new CacheConfig(); cfg.Path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Fiddler2", "Cache"); if (!Directory.Exists(cfg.Path)) { Directory.CreateDirectory(cfg.Path); } cfg.ConfigFile = System.IO.Path.Combine(cfg.Path, "config.json"); cfg.DBFile = System.IO.Path.Combine(cfg.Path, "db.cache"); cfg.CacheDir = System.IO.Path.Combine(cfg.Path, "Files"); if (!File.Exists(cfg.ConfigFile)) { cfg.Save(); } else { cfg = Newtonsoft.Json.JsonConvert.DeserializeObject<CacheConfig>(File.ReadAllText(cfg.ConfigFile, Encoding.UTF8)); } return cfg; }