Esempio n. 1
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            var key = this.txtKey.Text.Trim();
            if (string.IsNullOrEmpty(key))
            {
                MessageBox.Show("请输入key值");
                return;
            }

            if (MessageBox.Show("确定要删除?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
            {
                return;
            }

            try
            {
                using (var redis = new RedisRepository())
                {
                    var keys = redis.SearchKeys(key);
                    if (!keys.Any())
                    {
                        MessageBox.Show("暂无结果!");
                        return;
                    }
                    redis.DelKeys(keys);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("删除失败!");
            }

            MessageBox.Show("删除成功!");
        }
Esempio n. 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            var key = this.txtKey.Text.Trim();
            if (string.IsNullOrEmpty(key))
            {
                MessageBox.Show("请输入key值");
                return;
            }

            try
            {
                using (var redis = new RedisRepository())
                {
                    var keys = redis.SearchKeys(key);
                    if (!keys.Any())
                    {
                        MessageBox.Show("暂无结果!");
                        return;
                    }

                    foreach (var item in keys)
                    {
                        this.lstResult.Items.Add(item);
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("查询失败!");
            }
        }