示例#1
0
        /// <summary>
        /// Node Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treDBList_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            Thread thread = new Thread(() =>
            {
                var connNode = e.Node;
                if (connNode == null)
                {
                    return;
                }

                this.BeginInvoke((MethodInvoker) delegate
                {
                    RefreshTreeListNodeStatus(connNode, Index_RedisWait);
                });

                var connNodeTag = connNode.Tag as RedisConnConfig;
                if (connNodeTag != null)
                {
                    using (var redisSocket = new RedisSocketClient(connNodeTag.Host, connNodeTag.Port))
                    {
                        var dictDbInfo = redisSocket.GetRedisDbAndDbSize();
                        this.BeginInvoke((MethodInvoker) delegate
                        {
                            BindDbToTree(connNode, dictDbInfo, connNodeTag);
                        });

                        this.BeginInvoke((MethodInvoker) delegate
                        {
                            RefreshTreeListNodeStatus(connNode, Index_RedisOnline);
                        });
                    }
                }
                else
                {
                    var nodeInfo = connNode.Tag as RedisDbNodeInfo;
                    if (nodeInfo != null)
                    {
                        using (var redisSocket = new RedisSocketClient(nodeInfo.ParentHost, nodeInfo.ParentPort))
                        {
                            var keys = redisSocket.GetAllKeysByDb(nodeInfo.Db).OrderBy(x => x).ToList();
                            this.BeginInvoke((MethodInvoker) delegate
                            {
                                BindKeysToTree(connNode, keys);
                            });

                            this.BeginInvoke((MethodInvoker) delegate
                            {
                                RefreshTreeListNodeStatus(connNode, Index_RedisDb);
                            });
                        }
                    }
                }
            });

            thread.Start();
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="config"></param>
        public RedisClient(RedisConnConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("The Argument config is null.");
            }

            this._config       = config;
            this._socketClient = new RedisSocketClient(this._config.Host, this._config.Port,
                                                       this._config.Auth, this._config.ConnectionTimeOut);

            if (this._socketClient == null)
            {
                throw new ArgumentException("The RedisSocketClient is null.");
            }
        }