Redis Learning-Getting Started

Source: Internet
Author: User

C:\Program Files\redis\redis-cli.exe

Using Servicestack.redis

Class Program
{
static void Main (string[] args)
{

Redisclient client = new Redisclient ("127.0.0.1", 6379);
Client. Flushall ();//Clear data
Client. Changedb (0);//Use Db0
Stopwatch sw=new Stopwatch ();
Sw. Reset ();
Sw. Start ();
list<keyvaluepair<string, string>> keyvaluepairs = new list<keyvaluepair<string, string>> ();

Insert 50W data into hash, up to 10W each time, hash up to 80w bar
for (int i2 = 0; i2 <= 4; i2++)
{
Keyvaluepairs.clear ();
for (int i22 = 0; i22 < 1000*100; i22++)
{
Keyvaluepairs.add (New keyvaluepair<string, string> ("key" + (i22+i2*1000*1000). ToString (), i22. ToString ()));
}
Client. Setrangeinhash ("xxx", keyvaluepairs);
}

Sw. Stop ();
var ts1 = sw. elapsedmilliseconds;//about 2 seconds.
Sw. Reset ();
Sw. Start ();
var dict= client. Getallentriesfromhash ("xxx");//Read All values
Sw. Stop ();
var ts2 = sw. elapsedmilliseconds;//about 1 seconds.

}

Redis Learning-Getting Started

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.