Reproduced in: http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/113.html?1455860686
Note: C # does not use the 4.0 version of the Servicestack.redis driver when calling Redis? Because this version has been commercialized, there will be a limit of 6,000 data per hour
1. Reference driver
The code is as follows:
Using Servicestack.redis;
2. Database connection
The code is as follows:
Redisclient client;
Connection Server 6379 is the default port for Redis
Client = new Redisclient ("127.0.0.1", 6379);
Client. Password = "";//Setting the password can not be commented
100,000 data tests, I found the efficiency of using set is significantly more efficient than using the store, and I found in the test that the store lost 7-80 or so of the number and set was not lost
Stopwatch SW = new Stopwatch ();
Sw. Start ();
for (int i = 0; i < 100000; i++)
{
Client. Set<gps> (Guid.NewGuid (). ToString (), New GPS
{
Direction = 287,
Gps_time = "1417622213418",
Lati = 29.310586,
Longi = 120.125143,
Pla_no = "Zhe A12345", #p # page title #e#
Pla_type = 1,
Speed = 23.5,
State = 0,
Carstate = 0,
Upload_time = "1417622088418"
});
Client. Store<gps> (
New GPS
{
Direction = 287,
Gps_time = "1417622213418",
Lati = 29.310586,
Longi = 120.125143,
Pla_no = "Zhe A12345",
Pla_type = 1,
Speed = 23.5,
State = 0,
Carstate = 0,
Upload_time = "1417622088418"
});
}
Sw. Stop ();
Console.WriteLine (SW. Elapsedmilliseconds);
Decimal Price = client. Get<decimal> ("price");//Get Data
Redis Summary Note (ii): simple example of C # connection to Redis