C # Redis Practice list,hashtable

Source: Internet
Author: User

Write in front

Recently, the company engaged in a campaign, using the Redis queue, the study of the next Redis related content. Also handy to do a demo.

Using Redis for C #

The associated assemblies for Reidis can be installed through NuGet. After installation, it is discovered that the following DLLs are introduced

Some list, queue, and Hashtable operations.

UsingSystem;UsingSystem.Collections.Generic;UsingSystem.Linq;UsingSystem.Text;UsingSystem.Threading.Tasks;UsingNservicekit.redis;UsingNewtonsoft.json;Namespaceredisdemo{Classprogram {Staticvoid Main (String[] args) {//Create a redis factory redisclientfactory factory =Redisclientfactory.instance;//Create Redisclient object Redisclient client = Factory through the factory. Createredisclient ("192.168.1.37",6379);//Adds a key-value pair to the client in the list. Additemtolist ("Test_listid","Wolfy");//Value by key and indexString value = client. Getitemfromlist ("Test_listid",0);//Queuefor (int i =0; I <10; i++) {client. Enqueueitemonlist ("Queue_test","Test" +i.ToString ()); }while (client. GetListCount ("Queue_test") >0{Console.WriteLine (client). Dequeueitemfromlist ("Queue_test")); }//Hashtablefor (int i =0; I <10; i++) {client. Setentryinhash ("Hashtable_test","Test "+ i.tostring (), Jsonconvert.serializeobject (new {id = i + 1, name = " wolfy I. ToString ()})); } // Gets the value in Hashtable list< string> lst = client. Gethashvalues ( "hashtable_test  "); foreach (var item in LST) {Console.WriteLine (item);} Console.read (); } }} 

Test

Summarize

About Redis Articles online There are many, here because of work needs, first started to get a demo, first run up, and then in-depth study.

Reprint: Blog Address: http://www.cnblogs.com/wolf-sun/

C # Redis Practice list,hashtable

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.