示例#1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public NoSqlSession()
        {
            var type = System.Configuration.ConfigurationManager.AppSettings["NoSqlType"];

            if (string.IsNullOrWhiteSpace(type))
            {
                throw new Exception("请在AppSetting中配置<add key=\"NoSqlType\" value=\"IIS/Redis/MongoDB/Memcache\" />");
            }

            switch (type.ToLower())
            {
            case "redis":
                NoSqlType = NoSqlType.Redis;
                Cache     = new Redis();
                break;

            case "iis":
                NoSqlType = NoSqlType.IIS;
                Cache     = new IIS();
                break;

            default:
                throw new Exception("暂时不支持的NoSql数据库!");
            }
        }
示例#2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public NoSqlSession(NoSqlType noSqlType, string host = "", string port = "", string pwd = "")
        {
            switch (noSqlType)
            {
            case NoSqlType.Redis:
                NoSqlType = NoSqlType.Redis;
                Cache     = new Redis(host, port, pwd);
                break;

            case NoSqlType.IIS:
                NoSqlType = NoSqlType.IIS;
                Cache     = new IIS();
                break;

            default:
                throw new Exception("暂时不支持的NoSql数据库!");
            }
        }