/// <summary> /// 获取缓存对象 自定义缓存类型 /// </summary> /// <returns></returns> public static ICache GetCacheObj(MCaching.Provider provider) { if (_cacheObj == null) { if (IsEnable) { switch (provider) { case MCaching.Provider.Redis: { _cacheObj = MRedisCache.GetInstance(); } break; case MCaching.Provider.Memcached: { _cacheObj = MMemcache.GetInstance(); } break; default: { MLogManager.Error(MLogGroup.Other.获取缓存对象, "", "缓存方式错误 没有指定 " + MCaching.Provider.Memcached + " 缓存的实现方法!"); } break; } } else { _cacheObj = NotCache.GetInstance(); } } return(_cacheObj); }
/// <summary> /// /// </summary> /// <returns></returns> public static NotCache GetInstance() { if (_obj == null) { lock (LockObj) if (_obj == null) { _obj = new NotCache(); } } return(_obj); }
/// <summary> /// 获取缓存对象 采用 配置文件配置 /// </summary> /// <returns></returns> public static ICache GetCacheObj() { if (_cacheObj == null) { if (IsEnable) { var key = MConfigManager.FormatKey("Default", MConfigs.ConfigsCategory.Cache); var cacheType = MConfigManager.GetAppSettingsValue(key, ""); if (!string.IsNullOrEmpty(cacheType)) { if (cacheType.Equals(MCaching.Provider.Redis.ToString(), StringComparison.OrdinalIgnoreCase)) { _cacheObj = MRedisCache.GetInstance(); } else if (cacheType.Equals(MCaching.Provider.Memcached.ToString(), StringComparison.OrdinalIgnoreCase)) { _cacheObj = MMemcache.GetInstance(); } else { MLogManager.Error(MLogGroup.Other.获取缓存对象, "", "缓存方式配置无法识别,节点" + key); } } else { MLogManager.Error(MLogGroup.Other.获取缓存对象, "", "请配置缓存方式,节点" + key); } } else { _cacheObj = NotCache.GetInstance(); } } return(_cacheObj); }