This section shows a download. NET how to use Redis to store data. The more common client class libraries in. NET are ServiceStack, and look at how the data is stored through ServiceStack.
DLL Download: Https://github.com/ServiceStack/ServiceStack.Redis
After the download is complete, the DLL includes four DLL files and then adds the four files to your project.
Redis includes four data types, Strings, Lists, sets, Sorted sets
Now let's look at these four types of usage
1. Connect to a Redis server
redisclient client; Private void button1_click (object sender, EventArgs e) { // Connection Server New redisclient ("127.0.0.1",6379); }
2.Strings type
Strings can store strings, numbers and the like, floating-point types, and so on. The basic types in net
Private voidButton2_Click (Objectsender, EventArgs e) { //Store user name and passwordClient. set<string> ("username","[email protected]"); Client. Set<int> ("pwd",123456); stringUsername = client. get<string> ("username"); intPwd=client. get<int> ("pwd"); Client. Set<decimal> (" Price",12.10M); decimalPrice = client. get<decimal> (" Price"); MessageBox.Show (price. ToString ()); MessageBox.Show ("User name:"+username+", Password:"+pwd. ToString ()); }
C # connecting the In-memory database Redis "1, redis storage read Data"