First-entry Redis----> Simple deployment

Source: Internet
Author: User
Tags redis server

Company project backstage useful to Redis, in my opinion has always felt very tall on, I this rookie Gao pan not up ha! With the idea of trying, I also tried the next.

    1. I downloaded Redis and saw the following files after decompression

      650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/89/B4/wKiom1gaChbxwYDoAAA2XtaLacE621.png-wh_500x0-wm_3 -wmp_4-s_2749902050.png "title=" Redis.png "alt=" Wkiom1gachbxwydoaaa2xtalace621.png-wh_50 "/>

      guess the words redis-server.exe refers to the server side, and Redis-cli.exe refers to the client, redis.conf should be the configuration file it, I think it should have guessed wrong!

      Open the configuration file, a face confused, for the English slag I simply is ignorant force of n Times Square, nothing, have degrees Niang in hand, should be able to understand a bit.

2. first open vs, create a console.

3. refer to the corresponding DLL first, as shown in 650) this.width=650; "Src=" http://s5.51cto.com/wyfs02/M01/89/B2/ Wkiol1gadd7glbitaadrcruwouo549.png-wh_500x0-wm_3-wmp_4-s_2657763539.png "title=" LibDll.png "alt=" Wkiol1gadd7glbitaadrcruwouo549.png-wh_50 "/>

4. Create a Redis object first, as we know from the following code

using system;namespace servicestack.redis{    //  Abstract:      //     provide the default factory implementation  for creating a RedisClient that    //      can be mocked and used by different  ' Redis client managers '     public class RedisClientFactory : IRedisClientFactory     {        //from here, we can get a redisclientfactory  object by invoking the instance         public static RedisClientFactory Instance;         public redisclientfactory ();                 //Get redisclientfactory  Object, we can call this method to create the redisclient  instance  &Nbsp;      public redisclient createredisclient (String host,  int port);     }}

5.

        static string ip =  "127.0.0.1";         static int port = 6379;         static void main (String[] args)          {            //Start Call              //1  determine the IP (127.0.0.1) +port  of the Redis server (default 6379)             //2  instantiate client instances of Redis              using  (var client =  RedisClientFactory.Instance.CreateRedisClient (ip,port))              {                The value of the  //redis  key can be String,lisT<>,set,                  //uses set to store data: feature: If key does not exist, create it, or new data                  client. Set<string> ("name1",  "Smallhan");                 console.writeline (client. Get<string> ("name1"));                 //List                 console.writeline ();                 console.writeline ("Use list");                 var list = new List<string> () {                      "Xiao Han", "Xiao Lu", "Xiao Ming"                  };                 foreach  (var it in list)                  {                     client. Additemtolist ("list",  it);                 }                 var resultlist = client. Getallitemsfromlist ("list");                 resultlist.foreach (C => console.writeline (c));                 //set                 console.writeline ();                 console.writeline ("Use Set");                 client. Additemtoset ("1",  "2");                 client. Additemtoset ("1",  "2");                 client. Additemtoset ("1",  "3");                 client. Getallitemsfromset ("1"). ToList (). ForEach (C => console.writeline (c));             }     &nBsp;      console.readkey ();        } 

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/89/B4/wKiom1gaDnyyJNopAAGLYo-kxAo713.png-wh_500x0-wm_3 -wmp_4-s_81078150.png "title=" Result.png "alt=" Wkiom1gadnyyjnopaaglyo-kxao713.png-wh_50 "/>

6. The simplest Redis read and write, but in the runtime remember to open the service, but when the server restarts, the data we save will be lost, because it is stored in the server memory, we can be configured through the configuration file configuration, the memory of the data persisted to the server hard disk.

This article from "11581236" blog, declined reprint!

First-entry Redis----> Simple deployment

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.