Redis Summary Notes (ii): C # Connection Redis Simple Example _redis

Source: Internet
Author: User
Tags redis

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.