注:C#在调用Redis是永不采取ServiceStack.Redis驱动的4.0版本,因为这几个本子现已商业化了,会身不由己每时辰6000条数据的界定

1、引用驱动复制代码 代码如下: using
ServiceStack.Redis;2、数据库连接复制代码 代码如下: RedisClient client;
//连接服务器 6379是redis的暗中同意端口 client = new RedisClient(“127.0.0.1”,
6379卡塔尔(قطر‎; client.Password = “”;//设置密码 没有得以注释

//10万条数据测量检验,小编发觉选拔set的成效显然比接收store的频率高,并且在测量试验进度中自小编发觉store会错失7-80条左右的数而set却一条都还未丢
Stopwatch sw = new Stopwatch(State of Qatar; sw.Start(卡塔尔国;

for (int i = 0; i 100000; i++) {
client.SetGPS(Guid.NewGuid().ToString(), new GPS { direction = 287,
gps_time = “1417622213418”, lati = 29.310586, longi = 120.125143,
pla_no = “浙A12345”, pla_type = 1, speed = 23.5, state = 0, carstate =
0, upload_time = “1417622088418” });

client.StoreGPS( new GPS { direction = 287, gps_time = “1417622213418”,
lati = 29.310586, longi = 120.125143, pla_no = “浙A12345”, pla_type =
1, speed = 23.5, state = 0, carstate = 0, upload_time = “1417622088418”
}); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds);

decimal price = client.Getdecimal(“price”卡塔尔;//获取数据