public override void InitSetting(IEnumerable <SettingNode> settingNodes) { base.InitSetting(settingNodes); firstCache = CacheUtil.TryCreateCache(settingNodes, "firstType"); secondCache = CacheUtil.TryCreateCache(settingNodes, "secondType"); if (firstCache == null) { firstCache = new AspnetCache(); } if (secondCache == null) { throw new MissConfigurationException(settingNodes, "secondType"); } if (firstCache.GetType() == secondCache.GetType()) { throw new ConfigurationException(String.Format("一二级缓存的类型不能一致,当前皆为 {0}。", firstCache.GetType().FullName)); } if (firstCache != this) { CacheUtil.InitCache(firstCache, CacheUtil.GetCacheSettingNode(settingNodes, firstCache)); } if (secondCache != this) { CacheUtil.InitCache(secondCache, CacheUtil.GetCacheSettingNode(settingNodes, secondCache)); } }
public ICache GetCacher(string name) { ICache cache = CacheUtil.GetDefaultCache(); if (cache is AbstractCache) { ((AbstractCache)cache).CacheName = name; } return(cache); }
public static ICache GetDefaultCache(bool init = true) { SettingNode cacheNode = ToolSection.Instance.TryGetNode("cache"); List <SettingNode> settingNodes = new List <SettingNode> { cacheNode }; ICache cache = CacheUtil.TryCreateCache(cacheNode, "type"); if (cache == null) { cache = new AspnetCache(); } if (init) { CacheUtil.InitCache(cache, CacheUtil.GetCacheSettingNode(settingNodes, cache)); } return(cache); }
protected IEnumerable <SettingNode> TryGetNodes(IEnumerable <SettingNode> settingNodes, string path) { return(CacheUtil.TryGetNodes(settingNodes, path)); }
protected string TryGetValue(IEnumerable <SettingNode> settingNodes, string path) { return(CacheUtil.TryGetValue(settingNodes, path)); }