本文整理汇总了C#中ServiceStack.Redis.RedisClient.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.Remove方法的具体用法?C# RedisClient.Remove怎么用?C# RedisClient.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.Redis.RedisClient
的用法示例。
在下文中一共展示了RedisClient.Remove方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button2_Click
private void button2_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var id = "58231";
var compactkey = string.Format(RedisKey.KeyCompanyNewsCompact, id);
if (redis.ContainsKey(compactkey))
redis.Remove(compactkey);
var detailkey = string.Format(RedisKey.KeyCompanyNewsDetail, id);
if (redis.ContainsKey(detailkey))
redis.Remove(detailkey);
}
示例2: CleanActivityData
public void CleanActivityData()
{
RedisClient cli = new RedisClient();
var master = cli.Sets["activity-master"];
var sets = master.GetAll();
foreach(var set in sets)
{
cli.Remove(set);
master.Remove(set);
}
}
示例3: simpleRedisGetSet
static void simpleRedisGetSet()
{
string host = "localhost";
string elementKey = "testKeyRedis";
RedisClient redisclient = new RedisClient(host);
redisclient.Remove(elementKey);
var storeMembers = new List<string> { "asd","dsd","bb"};
// storeMembers.ForEach(x=>redisclient.AddItemToList(elementKey,x));
redisclient.AddRangeToList(elementKey,storeMembers);
var members = redisclient.GetAllItemsFromList(elementKey);
var list = redisclient.Lists[elementKey];
list.Clear();
var ser = new ObjectSerializer();
bool result = redisclient.Set<byte[]>(elementKey, ser.Serialize(storeMembers));
if (result)
{
var resultlist = ser.Deserialize(redisclient.Get<byte[]>(elementKey));
}
members.ForEach(s=>Console.WriteLine("list:"+s));
// Console.WriteLine("index2:"+redisclient.GetItemFromList(elementKey,1));
//if (redisclient.Get<string>(elementKey) == null)
//{
// redisclient.Set(elementKey, "defaultValue");
//}
//else {
// redisclient.Set(elementKey, "new default value");
//}
//Console.WriteLine("redise:value:"+redisclient.Get<string>(elementKey));
Console.WriteLine(redisclient.Info);
}
示例4: Can_failover_at_runtime
public void Can_failover_at_runtime()
{
var failoverHost = "redis-failover:6379";
string key = "test:failover";
var localClient = new RedisClient("localhost");
localClient.Remove(key);
var failoverClient = new RedisClient(failoverHost);
failoverClient.Remove(key);
var clientManager = new PooledRedisClientManager(new[] { "localhost" });
RunInLoop(clientManager, callback:() =>
{
lock (clientManager)
Monitor.Pulse(clientManager);
});
Thread.Sleep(100);
clientManager.FailoverTo(failoverHost);
lock (clientManager)
Monitor.Wait(clientManager);
var localIncr = localClient.Get<int>(key);
var failoverIncr = failoverClient.Get<int>(key);
Assert.That(localIncr, Is.GreaterThan(0));
Assert.That(failoverIncr, Is.GreaterThan(0));
Assert.That(localIncr + failoverIncr, Is.EqualTo(100));
}
示例5: UpdateCeoImage
public void UpdateCeoImage()
{
try
{
if ((ConfigurationManager.AppSettings["CeoImageAllowance"] ?? "") != "TRUE") return;
var bfirstTime = true;
//Thread.Sleep(index * 1000);
var sql = new SqlDb();
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
while (ServiceStarted)
{
try
{
if (!bfirstTime) Thread.Sleep(reportInterval);
bfirstTime = false;
sql.OpenDb();
var ldt = sql.GetAllLandProjects();
//var cdt = sql.GetAllCeos();
sql.CloseDb();
landImages = GetAllLandImages();
var keys = redis.SearchKeys(string.Format(RedisKey.BDSKey, "*", "*"));
foreach(var key in keys)
{
var t = key.Substring(key.IndexOf(":tiendocode:"), key.IndexOf(":Object") - key.IndexOf(":tiendocode:")).Replace(":tiendocode:", "");
if (ldt.Select("MaTienDo = '" + t + "'").Length == 0)
{
redis.Remove(key);
continue;
}
var o = redis.Get<TienDoBDS>(key);
if(o==null) continue;
var s = o.MaTienDo;
if (string.IsNullOrEmpty(s)) continue;
o.BDSImages = landImages.FindAll(i => i.ToUpper().StartsWith(s));
redis.Set(key, o);
}
ceoPhotos = GetCeoPhotos();
foreach (var photo in ceoPhotos)
{
if (!photo.Contains(".")) continue;
var code = photo.Substring(0, photo.IndexOf("."));
if (redis.ContainsKey(string.Format(RedisKey.CeoImage, code)))
{
redis.Set(string.Format(RedisKey.CeoImage, code), photo);
}
else
{
redis.Add(string.Format(RedisKey.CeoImage, code), photo);
}
//var o = redis.Get<Ceo>(string.Format(RedisKey.CeoKey, code));
//if (o == null) continue;
//o.CeoImage = photo;
//redis.Set(string.Format(RedisKey.CeoKey, code), o);
}
var keywords = SqlDb.GetGoogleTag(-1);
var ls = new List<string>();
foreach (DataRow keyword in keywords.Rows)
{
if(!ls.Contains(keyword["keyword"].ToString())) ls.Add(keyword["keyword"].ToString());
}
//if (redis.ContainsKey(RedisKey.GoogleTag))
// redis.Set(RedisKey.GoogleTag, ls);
//else
// redis.Add(RedisKey.GoogleTag, ls);
}
catch (Exception ex)
{
log.WriteEntry("UpdateCeoImage - " + ex.ToString(), EventLogEntryType.Error);
}
}
}
catch (Exception ex)
{
log.WriteEntry("UpdateCeoImage - " + ex.ToString(), EventLogEntryType.Error);
}
}
示例6: UpdateList
//.........这里部分代码省略.........
case "FIT":
#region FIT
try
{
var keylist = string.Format(RedisKey.InternalHistoryKeys, symbol);
var ls = new List<string>(); //redis.ContainsKey(keylist) ? redis.Get<List<String>>(keylist) : new List<string>();
var pdt = sql.GetInternalHistory(symbol, -1);
foreach (DataRow pdr in pdt.Rows)
{
var key = string.Format(RedisKey.InternalHistory, symbol, (((DateTime?)pdr["NgayThongBao"]) ?? DateTime.Now).ToString("yyyyMMdd"), pdr["ID"], pdr["ShareHolder_ID"] + ":" + pdr["ShareHolderCode"]);
var order = new InternalHistory() { Stock = symbol, RelatedMan = pdr["NguoiLienQuan"].ToString(), RelatedManPosition = pdr["ChucVuNguoiLienQuan"].ToString(), VolumeBeforeTransaction = double.Parse(pdr["SLCPTruocGD"].ToString()), PlanBuyVolume = double.Parse(pdr["DangKy_Mua"].ToString()), PlanSellVolume = double.Parse(pdr["DangKy_Ban"].ToString()), PlanBeginDate = pdr["DangKy_TuNgay"].Equals(DBNull.Value) ? null : (DateTime?)pdr["DangKy_TuNgay"], PlanEndDate = pdr["DangKy_DenNgay"].Equals(DBNull.Value) ? null : (DateTime?)pdr["DangKy_DenNgay"], RealBuyVolume = double.Parse(pdr["ThucHien_Mua"].ToString()), RealSellVolume = double.Parse(pdr["ThucHien_Ban"].ToString()), RealEndDate = pdr["ThucHien_NgayKetThuc"].Equals(DBNull.Value) ? null : (DateTime?)pdr["ThucHien_NgayKetThuc"], PublishedDate = pdr["NgayThongBao"].Equals(DBNull.Value) ? null : (DateTime?)pdr["NgayThongBao"], VolumeAfterTransaction = double.Parse(pdr["SLCPSauGD"].ToString()), TransactionNote = pdr["GhiChu"].ToString(), HolderID = pdr["ShareHolder_ID"].ToString(), ShareHolderCode = pdr["ShareHolderCode"].ToString() }; //TransactionMan = pdr["FullName"].ToString(), TransactionManPosition = pdr["ChucVu"].ToString(),
var tochuc = pdr["ToChuc"].ToString();
order.TransactionMan = tochuc.IndexOf("--") > 0 ? tochuc.Substring(0, tochuc.IndexOf("--")) : tochuc;
order.TransactionManPosition = tochuc.IndexOf("--") > 0 && tochuc.IndexOf("--") < tochuc.Length - 2 ? tochuc.Substring(tochuc.IndexOf("--") + 2) : "";
if (redis.ContainsKey(key))
redis.Set<InternalHistory>(key, order);
else
redis.Add<InternalHistory>(key, order);
if (!ls.Contains(key)) ls.Add(key);
}
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
redis.Set<List<string>>(keylist, ls);
else
redis.Add<List<string>>(keylist, ls);
var internalkeys = redis.SearchKeys(string.Format(RedisKey.InternalHistory, symbol, "*", "*", "*")) ?? new List<string>();
foreach (var internalkey in internalkeys)
{
if(!ls.Contains(internalkey)) redis.Remove(internalkey);
}
}
catch (Exception ex)
{
log.WriteEntry(symbol + " : FIT : " + ex.ToString(), EventLogEntryType.Error);
ret = false;
}
#endregion
break;
case "FFT":
#region FFT
try
{
var keylist = string.Format(RedisKey.ForeignHistoryKeys, symbol);
var ls = redis.ContainsKey(keylist) ? redis.Get<List<String>>(keylist) : new List<string>();
var pdt = (date == "" || ls.Count == 0) ? sql.GetForeignHistory(symbol, -1) : sql.GetForeignHistory(symbol, date);
foreach (DataRow pdr in pdt.Rows)
{
var key = string.Format(RedisKey.ForeignHistory, symbol, ((DateTime)pdr["Trading_Date"]).ToString("yyyyMMdd"));
var order = new ForeignHistory() { TradeDate = (DateTime)pdr["Trading_Date"], BuyVolume = double.Parse(pdr["Buying_Volume"].ToString()), BuyValue = double.Parse(pdr["Buying_Value"].ToString()), SellVolume = double.Parse(pdr["Selling_Volume"].ToString()), SellValue = double.Parse(pdr["Selling_Value"].ToString()), Room = double.Parse(pdr["CurrentRoom"].ToString()), TotalRoom = double.Parse(pdr["TotalRoom"].ToString()), Percent = double.Parse(pdr["SoHuu"].ToString()), Symbol = symbol }; //, BasicPrice = double.Parse(pdr["BasicPrice"].ToString()), ClosePrice = double.Parse(pdr["ClosePrice"].ToString()), AveragePrice = double.Parse(pdr["AveragePrice"].ToString())
if (redis.ContainsKey(key))
redis.Set<ForeignHistory>(key, order);
else
redis.Add<ForeignHistory>(key, order);
if (!ls.Contains(key)) ls.Add(key);
}
ls.Sort();
ls.Reverse();
if (redis.ContainsKey(keylist))
示例7: button23_Click
private void button23_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var sql = new SqlDb();
sql.OpenDb();
var date = "";
#region Lịch sự kiện
var lskdt = sql.GetLichSuKien(date);
var keys = redis.ContainsKey(RedisKey.KeyLichSuKien) ? redis.Get<List<string>>(RedisKey.KeyLichSuKien) : new List<string>();
var removals = keys.FindAll(s => s.Substring(0, 8) == date.Replace(".", ""));
foreach (var removal in removals)
{
var key = string.Format(RedisKey.KeyLichSuKienObject, removal.Substring(removal.LastIndexOf(":") + 1));
if (redis.ContainsKey(key)) redis.Remove(key);
keys.Remove(removal);
}
foreach (DataRow ldr in lskdt.Rows)
{
var o = new LichSuKien() { ID = int.Parse(ldr["ID"].ToString()), LoaiSuKien = ldr["EventType_List"].ToString(), MaCK = ldr["StockSymbols"].ToString(), MaSan = 0, News_ID = ldr["News_ID"].ToString(), Title = ldr["EventTitle"].ToString(), NgayBatDau = ldr["NgayBatDau"].ToString(), NgayKetThuc = ldr["NgayKetThuc"].ToString(), NgayThucHien = ldr["NgayThucHien"].ToString(), TenCty = "", TomTat = "", PostDate = (DateTime) ldr["PostDate"]};
try
{
o.EventDate = (DateTime) ldr["EventDate"];
}catch(Exception)
{
o.EventDate = DateTime.Parse("2000-01-01");
}
var key = string.Format(RedisKey.KeyLichSuKienObject, o.ID);
if (redis.ContainsKey(key))
redis.Set(key, o);
else
redis.Add(key, o);
key = string.Format(RedisKey.KeyLichSuKienObjectInList, o.EventDate.ToString("yyyyMMdd"), string.IsNullOrEmpty(o.LoaiSuKien.Trim())? "_" : o.LoaiSuKien, o.ID);
if (!keys.Contains(key)) keys.Add(key);
}
if (redis.ContainsKey(RedisKey.KeyLichSuKien))
redis.Set(RedisKey.KeyLichSuKien, keys);
else
redis.Add(RedisKey.KeyLichSuKien, keys);
#endregion
#region Lịch sự kiện tóm tắt
lskdt = sql.GetLichSuKienTomTat();
var lls = new List<LichSuKien>();
foreach (DataRow ldr in lskdt.Rows)
{
var o = new LichSuKien() { ID = int.Parse(ldr["ID"].ToString()), LoaiSuKien = ldr["EventType_List"].ToString(), MaCK = ldr["StockSymbols"].ToString(), MaSan = 0, News_ID = ldr["News_ID"].ToString(), Title = ldr["EventTitle"].ToString(), NgayBatDau = ldr["NgayBatDau"].ToString(), NgayKetThuc = ldr["NgayKetThuc"].ToString(), NgayThucHien = ldr["NgayThucHien"].ToString(), TenCty = "", TomTat = "", PostDate = (DateTime)ldr["PostDate"] };
try
{
o.EventDate = (DateTime)ldr["EventDate"];
}
catch (Exception)
{
o.EventDate = DateTime.Parse("2000-01-01");
}
lls.Add(o);
}
if (redis.ContainsKey(RedisKey.KeyLichSuKienTomTat))
redis.Set(RedisKey.KeyLichSuKienTomTat, lls);
else
redis.Add(RedisKey.KeyLichSuKienTomTat, lls);
#endregion
sql.CloseDb();
}
示例8: button22_Click
private void button22_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var keys = redis.SearchKeys(string.Format(RedisKey.BDSKey, "*"));
var sql = new SqlDb();
sql.OpenDb();
var dt = sql.GetAllLandProjects();
var i = 0;
foreach (var key in keys)
{
//ceo:ceocode:{0}:Object
var t = key.Replace("tiendoBDS:tiendocode:", "").Replace(":Object", "");
if (dt.Select("MaTienDo = '" + t + "'").Length == 0)
{
redis.Remove(key);
i++;
}
}
sql.CloseDb();
MessageBox.Show(i.ToString("#,##0"));
}
示例9: button14_Click
private void button14_Click(object sender, EventArgs e)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var symbol = "CEO_00662";
var sql = new SqlDb();
#region CEO
var ceokey = string.Format(RedisKey.CeoKey, symbol);
var cdt = sql.GetCeosNew_Profile(symbol);
if (cdt.Rows.Count == 0)
{
if (redis.ContainsKey(ceokey)) redis.Remove(ceokey);
}
else
{
var ceo = new Ceo();
ceo.CeoName = cdt.Rows[0]["CeoName"].ToString(); ceo.CeoBirthday = cdt.Rows[0]["CeoBirthday"].ToString(); ceo.CeoIdNo = cdt.Rows[0]["CeoIdNo"].ToString(); ceo.CeoAchievements = cdt.Rows[0]["CeoAchievements"].ToString(); ceo.CeoHomeTown = cdt.Rows[0]["CeoHomeTown"].ToString(); ceo.CeoSchoolDegree = cdt.Rows[0]["CeoLevel"].ToString();
ceo.CeoCode = cdt.Rows[0]["CeoCode"].ToString();
if (ceo.CeoBirthday != "" && ceo.CeoBirthday.Contains("/"))
{
ceo.CeoBirthday = ceo.CeoBirthday.Substring(ceo.CeoBirthday.LastIndexOf("/") + 1);
}
ceo.CeoImage = "";
//photo
//school title
var css = new List<CeoSchool>();
var sdt = sql.GetCeosNew_School(symbol);
foreach (DataRow sdr in sdt.Rows)
{
css.Add(new CeoSchool() { CeoTitle = sdr["CeoTitle"].ToString(), SchoolTitle = sdr["SchoolTitle"].ToString(), SchoolYear = sdr["SchoolYear"].ToString() });
}
ceo.CeoSchool = css;
//ceo position
var cps = new List<CeoPosition>();
var pdt = sql.GetCeosNew_Position(symbol);
foreach (DataRow pdr in pdt.Rows)
{
var cp = new CeoPosition() { PositionTitle = pdr["PositionTitle"].ToString(), PositionCompany = pdr["PositionCompany"].ToString() };
if (string.IsNullOrEmpty(cp.PositionTitle)) cp.PositionTitle = pdr["PositionName"].ToString();
if (string.IsNullOrEmpty(cp.PositionCompany)) cp.PositionCompany = pdr["FullName"].ToString();
//__/01/2007
string cpd = pdr["CeoPosDate"].ToString();
if (cpd.Contains("/"))
{
int day, month, year;
if (!int.TryParse(cpd.Substring(0, cpd.IndexOf("/")), out day)) day = 0;
cpd = cpd.Substring(cpd.IndexOf("/") + 1);
if (!int.TryParse(cpd.Substring(0, cpd.IndexOf("/")), out month)) month = 0;
cpd = cpd.Substring(cpd.IndexOf("/") + 1);
if (!int.TryParse(cpd, out year)) year = 0;
if (year == 0)
{
cp.CeoPosDate = "";
}
else if (day == 0 && month == 0)
{
cp.CeoPosDate = "" + year;
}
else if (month > 0 && day == 0)
{
cp.CeoPosDate = month + "/" + year;
}
else if (day > 0 && month > 0)
{
cp.CeoPosDate = day + "/" + month + "/" + year;
}
else
{
cp.CeoPosDate = "";
}
}
cps.Add(cp);
}
ceo.CeoPosition = cps;
//asset
var cas = new List<CeoAsset>();
var adt = sql.GetCeosNew_Asset(symbol);
foreach (DataRow adr in adt.Rows)
{
cas.Add(new CeoAsset() { Symbol = adr["Symbol"].ToString(), AssetVolume = double.Parse(adr["AssetVolume"].ToString()).ToString("#,##0"), UpdatedDate = ((DateTime)adr["UpdatedDate"]).ToString("MM/yyyy") });
}
ceo.CeoAsset = cas;
//relation
var crs = new List<CeoRelation>();
var rdt = sql.GetCeosNew_Relation(symbol);
foreach (DataRow rdr in rdt.Rows)
{
crs.Add(new CeoRelation() { Symbol = rdr["Symbol"].ToString(), AssetVolume = double.Parse(rdr["AssetVolume"].ToString()).ToString("#,##0"), UpdatedDate = ((DateTime)rdr["UpdatedDate"]).ToString("MM/yyyy"), Name = rdr["CeoName"].ToString(), CeoCode = rdr["CeoCode"].ToString(), RelationTitle = rdr["RelationTitle"].ToString() });
}
ceo.CeoRelation = crs;
//process
var cos = new List<CeoProcess>();
var odt = sql.GetCeosNew_Process(symbol);
foreach (DataRow odr in odt.Rows)
//.........这里部分代码省略.........
示例10: Index
public ActionResult Index()
{
string message = string.Empty;
string host = "localhost";
using (var redisClient = new RedisClient(host))
{
//Create a 'strongly-typed' API that makes all Redis Value operations to apply against Phones
IRedisTypedClient<Phone> redis = redisClient.As<Phone>();
//Redis lists implement IList<T> while Redis sets implement ICollection<T>
IRedisList<Phone> mostSelling = redis.Lists["urn:phones:mostselling"];
IRedisList<Phone> oldCollection = redis.Lists["urn:phones:oldcollection"];
Person phonesOwner = new Person
{
Id = 7,
Age = 90,
Name = "OldOne",
Profession = "sportsmen",
Surname = "OldManSurname"
};
// adding new items to the list
mostSelling.Add(new Phone
{
Id = 5,
Manufacturer = "Sony",
Model = "768564564566",
Owner = phonesOwner
});
mostSelling.Add(new Phone
{
Id = 8,
Manufacturer = "Motorolla",
Model = "324557546754",
Owner = phonesOwner
});
var upgradedPhone = new Phone
{
Id = 3,
Manufacturer = "LG",
Model = "634563456",
Owner = phonesOwner
};
mostSelling.Add(upgradedPhone);
// remove item from the list
oldCollection.Remove(upgradedPhone);
// find objects in the cache
IEnumerable<Phone> LGPhones = mostSelling.Where(ph => ph.Manufacturer == "LG");
// find specific
Phone singleElement = mostSelling.FirstOrDefault(ph => ph.Id == 8);
//reset sequence and delete all lists
redis.SetSequence(0);
redisClient.Remove("urn:phones:mostselling");
redisClient.Remove("urn:phones:oldcollection");
}
ViewBag.Message = message;
return View();
}