在string型別中,不僅可以儲存key-value中value是string型別,也可以儲存物件型別。
testmodel amodel = new testmodel();
amodel.id = 1;
amodel.name = "wongcony";
amodel.type = 1;
amodel.company = "nxin";
for (int i = 1; i < 1000000; i++)
但是如果把物件型別儲存在string型別中,redis自己會把物件資料轉換成json字串。當再次讀取時還需要對json字串進行反序列化。
物件型別最好儲存在hash中,可以提高儲存的效能。但是讀取資料時,無論是string還是hash都不消耗效能時間。
for (int j = 1; j < 1000000; j++)
結果testmodel amodel = new testmodel();
amodel.id = 1;
amodel.name = "wongcony";
amodel.type = 1;
amodel.company = "nxin";
//--------------------------------------------
//model已string型別存於redis
console.writeline("儲存於string中");
console.writeline(datetime.now.tostring("hh:mm:ss:fms"));
for (int i = 1; i < 1000000; i++)
console.writeline(datetime.now.tostring("hh:mm:ss:fms"));
var am=client.get("5000key");
console.writeline(datetime.now.tostring("hh:mm:ss:fms"));
console.writeline(am.company);
console.writeline("儲存於hash中");
//--------------------------------------------
//model已hash型別存於redis
console.writeline(datetime.now.tostring("hh:mm:ss:fms"));
for (int j = 1; j < 1000000; j++)
console.writeline(datetime.now.tostring("hh:mm:ss:fms"));
var hm = client.gethashvalues("5000hkey");
console.writeline(datetime.now.tostring("hh:mm:ss:fms"));
redis效能測試
redis 效能測試 1 測試機器 1顆4核 intel r xeon tm cpu 3.00ghz cpu 2g記憶體 測試前伺服器負載為 2 測試方式 php模組安裝redis下的php插入,提取測試。3 string 測試 測試 redis new redis redis connect 12...
Redis 效能測試
redis 效能測試是通過同時執行多個命令實現的。redis 效能測試的基本命令如下 redis benchmark option option value 以下例項同時執行 10000 個請求來檢測效能 redis benchmark n 10000 ping inline 141043.72 r...
Redis 效能測試
redis 效能測試是通過同一時候執行多個命令實現的。redis 效能測試的基本命令例如以下 redis benchmark option option value 下面例項同一時候執行 10000 個請求來檢測效能 redis benchmark n 10000 ping inline 14104...