public void Test_Throughput() { var bytes = this.RandomBytes(_messageSizeBytes); var swTotal = Stopwatch.StartNew(); var key = "test:bandwidth:" + bytes.Length; var bytesSent = 0; var bytesRecv = 0; using (var redisClient = new RedisNativeClient(Config.MasterHost)) { for (var i = 0; i < _count; i++) { var sw = Stopwatch.StartNew(); redisClient.Set(key, bytes); bytesSent += bytes.Length; Console.WriteLine("SEND {0} bytes in {1}ms", bytes.Length, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); var receivedBytes = redisClient.Get(key); bytesRecv += receivedBytes.Length; Console.WriteLine("RECV {0} bytes in {1}ms", receivedBytes.Length, sw.ElapsedMilliseconds); Console.WriteLine("TOTAL {0} bytes SENT {0} RECV {1} in {2}ms\n", bytesSent, bytesRecv, swTotal.ElapsedMilliseconds); } } }
public void Test_Throughput() { var bytes = RandomBytes(MessageSizeBytes); var swTotal = Stopwatch.StartNew(); var key = "test:bandwidth:" + bytes.Length; int bytesSent = 0; int bytesRecv = 0; using (var redisClient = new RedisNativeClient(RedisServer)) { Count.Times(x => { var sw = Stopwatch.StartNew(); redisClient.Set(key, bytes); bytesSent += bytes.Length; "SEND {0} bytes in {1}ms".Print(bytes.Length, sw.ElapsedMilliseconds); sw.Reset(); sw.Start(); var receivedBytes = redisClient.Get(key); bytesRecv += receivedBytes.Length; "RECV {0} bytes in {1}ms".Print(receivedBytes.Length, sw.ElapsedMilliseconds); "TOTAL {0} bytes SENT {0} RECV {1} in {2}ms\n".Print( bytesSent, bytesRecv, swTotal.ElapsedMilliseconds); }); } }
public string ReMulGet(RedisNativeClient rc) { string keys = mulget.Text; string[] keysval = keys.Split(';'); string vals = ""; foreach (string singlekey in keysval) { try { if (rc.Exists(singlekey) == 1) { vals = vals + rc.Get(singlekey) + ';'; } else { vals = vals + "ERROR!;"; } } catch { vals = vals + "ERROR!"; } } return(vals); }
protected void btnReOperate(object sender, EventArgs e) { RedisNativeClient rclient = new RedisNativeClient("192.168.1.207", 6379); try { string keyval = key3.Text.Trim(); int number = int.Parse(num.Text.Trim()); string selflag = Select1.Value; long renum; if (selflag.Equals("+")) { // int.Parse(rclient.Get(key)); //Int64 re = 0; byte[] valueGet = rclient.Get(keyval); //if(valueGet == null || // valueGet.Length <= 0 // || valueGet.Length > 8) //{ // return; //} //byte[] total = new byte[8]; //for (int i = 0; i < 8; i++ ) //{ // total[i] = 0; //} //for (int i = 0; i < valueGet.Length; i++) //{ // total[i] = valueGet[i]; //} //re = System.BitConverter.ToInt64(total, 0); renum = rclient.IncrBy(keyval, number); Response.Write("<script>window.alert('" + renum + "');window.location.href='../Mem_RedisTest.aspx'</script>"); } else if (selflag.Equals("-")) { renum = rclient.DecrBy(keyval, number); Response.Write("<script>window.alert('" + renum + "');window.location.href=../Mem_RedisTest.aspx'</script>"); } } catch (Exception ex) { Response.Write("<script>window.alert('" + ex.Message + "');window.location.href=../Mem_RedisTest.aspx'</script>"); } }
public static object LTGetObj(string key_space, string obj_id) { if (obj_id == null || key_space == null) { return(false); } string redis_key = key_space + ":" + obj_id; using (RedisNativeClient RNC = GetNativeClientForKeySpace(key_space)) { byte[] saved_content = RNC.Get(redis_key); if (saved_content == null) { return(null); } return(Serializer.DeSerialize(saved_content)); } }
protected void btnRedisLook(object sender, EventArgs e) { RedisNativeClient rclient = new RedisNativeClient("192.168.1.207", 6379); string keyval = key1.Text.Trim(); if (rclient.Exists(keyval) == 0) { Response.Write("<script>window.alert('Key值不存在!');window.location.href='../Mem_RedisTest.aspx'</script>"); } else if (rclient.Exists(keyval) == 1) { byte[] re = rclient.Get(keyval); string result = ""; foreach (byte r in re) { result = result + Convert.ToString(r); } Response.Write("<script>window.alert('" + result + "');window.location.href='../Mem_RedisTest.aspx'</script>"); } else { Response.Write("<script>window.alert('ERROR!');window.location.href='../Mem_RedisTest.aspx'</script>"); } }
public string Get(string key) { RedisNativeClient client = this.pool.GetRedisClient(key); return((client == null) ? null : UTF8String.ToString(client.Get(key))); }