Note: C # in the call Redis is not to use the Servicestack.redis-driven version 4.0, because this version has been commercialized, there will be 6,000 data per hour limit
1. Reference driver
Copy Code code as follows:
Using Servicestack.redis;
2. Database connection
Copy Code code as follows:
Redisclient client;
Connection Server 6379 is the default port for Redis
Client = new Redisclient ("127.0.0.1", 6379);
Client. Password = "";//Set Password not available to comment
100,000 data tests, I found that using set was significantly more efficient than using the store, and during the test I found that the store would lose about 7-80 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",
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