Example #1
0
        public static RedisClientService GetInstance(string cStr = null)
        {
            RedisClientService instance = null;

            if (cStr != null)
            {
                if (!instanceTable.TryGetValue(cStr, out instance))
                {
                    instance = new RedisClientService(cStr);
                    instanceTable.Add(cStr, instance);
                }
            }
            else
            {
                cStr = ConfigClass.JGet("RedisServerConnStr") as string;
                if (string.IsNullOrWhiteSpace(cStr))
                {
                    return(null);
                }

                instance = new RedisClientService(cStr);
                instanceTable.Add(cStr, instance);
            }

            instance.stackCount += 1;
            return(instance);
        }
Example #2
0
        /// <summary>
        /// 使用注意:
        /// 1. redis增加/删除因为将会压入操作队列,所以不会立即生效,如果有必要,需要调用RedisCommit(),或最后Commit()一次。
        /// 2. 实体数据需要添加 TableName, DataBaseFields 两个属性才能正确使用SQL,Redis不影响
        /// </summary>
        public DataService()
        {
            if (sqlServer == null)
            {
                sqlServer = SQLServerClientService.GetInstance();
            }

            if (redis == null)
            {
                redis = RedisClientService.GetInstance();
            }
        }