本文整理匯總了C#中ServiceStack.Redis.RedisClient.SearchKeys方法的典型用法代碼示例。如果您正苦於以下問題:C# RedisClient.SearchKeys方法的具體用法?C# RedisClient.SearchKeys怎麽用?C# RedisClient.SearchKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ServiceStack.Redis.RedisClient
的用法示例。
在下文中一共展示了RedisClient.SearchKeys方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Get
public List<GroupedError> Get()
{
var client = new RedisClient();
client.ChangeDb(2);
const string keyPattern = "elmah-error:*";
var errorLogKeys = client.SearchKeys(keyPattern);
IEnumerable<ErrorModel> allError = client.GetAll<ErrorModel>(errorLogKeys).Values;
return ErrorLogAnalyzer(allError);
}
示例2: IndexDomainOrSubdomain
private static void IndexDomainOrSubdomain(RedisClient Redis)
{
List<string> keys = Redis.SearchKeys("urn:link:domain-or-subdomain:*");
for (int i = 0; i < keys.Count; i++)
{
List<string> links = Redis.GetAllItemsFromList(keys[i]);
string domainOrSubdomain = keys[0].Substring(29);
Console.WriteLine(i + ": " + domainOrSubdomain);
Redis.SetEntryInHash("urn:link:domain-or-subdomain",
domainOrSubdomain, links.JsonSerialize());
}
}
示例3: GetTopBCTC
private List<Entity.BCTC> GetTopBCTC(string symbol, string type, int fromYear, int fromQuarter, int count)
{
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
var keys = redis.SearchKeys(string.Format(RedisKey.BCTCKey, symbol.Trim().ToUpper(), type.Trim().ToUpper(), fromQuarter > 0 ? 1 : 0, "*", "*"));
keys.Sort();
keys.Reverse();
var i = 0;
while (i < keys.Count)
{
if (i >= count) { keys.RemoveAt(i); continue; }
var tmp = keys[i].Substring(keys[i].Length - 6);
var year = int.Parse(tmp.Substring(0, 4));
var quarter = int.Parse(tmp.Substring(5));
if (year > fromYear) { keys.RemoveAt(i); continue; }
if (year == fromYear && quarter > fromQuarter) { keys.RemoveAt(i); continue; }
i++;
}
return keys.Count == 0 ? new List<Entity.BCTC>() : redis.GetAll<Entity.BCTC>(keys).Values.ToList();
}
示例4: DoTest
public static void DoTest()
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
RedisClient Client = new RedisClient("192.168.56.2", 6379);
stopWatch.Stop();
Console.WriteLine("RedisClient Construct 耗時:{0}ms。", stopWatch.ElapsedMilliseconds);
Boolean connected = Client.IsSocketConnected();
stopWatch.Restart();
string str = Client.Get<string>("city");
stopWatch.Stop();
Console.WriteLine("RedisClient Get 耗時:{0}ms。", stopWatch.ElapsedMilliseconds);
stopWatch.Restart();
Client.Set<String>("city", "China");
stopWatch.Stop();
Console.WriteLine("RedisClient Set 耗時:{0}ms。", stopWatch.ElapsedMilliseconds);
stopWatch.Restart();
str = Client.Get<string>("city");
stopWatch.Stop();
Console.WriteLine("RedisClient Get 耗時:{0}ms。", stopWatch.ElapsedMilliseconds);
stopWatch.Restart();
Boolean req = Client.Add<String>("country", "China", new TimeSpan(0, 0, 1, 0));
stopWatch.Stop();
Console.WriteLine("RedisClient Add 耗時:{0}ms。", stopWatch.ElapsedMilliseconds);
List<String> keys = Client.SearchKeys("MBSOA:*");
Console.WriteLine("之前通過客戶端進行設置的city鍵值對:{0}", str);
Console.ReadLine();
}
示例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
//.........這裏部分代碼省略.........
}
#endregion
break;
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);
}
示例7: SaveToDb
public void SaveToDb()
{
try
{
var done = new List<string>();
var lastDate = DateTime.Now.AddDays(-1);
var bfirstTime = true;
var redis = new RedisClient(ConfigRedis.Host, ConfigRedis.Port);
while (ServiceStarted)
{
try
{
if (lastDate.ToString("yyyyMMdd") != DateTime.Now.ToString("yyyyMMdd"))
{
//reset time
done = new List<string>();
lastDate = DateTime.Now;
}
if (!bfirstTime) Thread.Sleep(noTradeInterval);
bfirstTime = false;
var keys = redis.SearchKeys(string.Format(RedisKey.SessionPrice, "*", DateTime.Now.ToString("yyyyMMdd"), "*"));
var count = 0;
if (keys != null)
{
var xml = "<root>";
var tmp = new List<string>();
foreach (var key in keys)
{
if (done.Contains(key)) continue;
var o = redis.Get<SessionPriceData>(key);
if (o == null) continue;
count++;
xml += string.Format("<info><sym>{0}</sym><price>{1}</price><vol>{2}</vol><tvol>{3}</tvol><tval>{4}</tval><time>{5}</time></info>", o.Symbol, o.Price, o.Volume, o.TotalVolume, o.TotalValue, o.TradeDate.ToString("yyyy-MM-dd HH:mm:ss"));
tmp.Add(key);
if (count >= 1000)
{
try
{
xml += "</root>";
SqlDb.UpdateData(xml);
Thread.Sleep(tradeInterval);
foreach (var item in tmp)
{
done.Add(item);
}
tmp = new List<string>();
xml = "<root>";
count = 0;
}
catch (Exception ex)
{
log.WriteEntry("SaveToDb : " + ex.ToString(), EventLogEntryType.Error);
}
}
}
if (tmp.Count > 0)
{
xml += "</root>";
try
{
SqlDb.UpdateData(xml);
foreach (var item in tmp)
{
done.Add(item);
}
}
catch (Exception ex)
{
log.WriteEntry("SaveToDb : " + ex.ToString(), EventLogEntryType.Error);
}
}
}
}
catch (Exception ex)
{
log.WriteEntry("SaveToDb : " + ex.ToString(), EventLogEntryType.Error);
}
}
}
catch (Exception ex)
{
log.WriteEntry("SaveToDb : " + ex.ToString(), EventLogEntryType.Error);
}
}
示例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"));
}