private void button21_Click(object sender, EventArgs e) { var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port); var keys = redis.SearchKeys(string.Format(RedisKey.CeoKey, "*")); var sql = new SqlDb(); sql.OpenDb(); var dt = sql.GetAllCeos(); var i = 0; foreach(var key in keys) { //ceo:ceocode:{0}:Object var t = key.Replace("ceo:ceocode:", "").Replace(":Object",""); if (dt.Select("CeoCode = '" + t + "'").Length==0) { redis.Remove(key); i++; } } sql.CloseDb(); MessageBox.Show(i.ToString("#,##0")); }