redis 初步认识二

前置:服务器安装redis

1.引用redis

2.使用redis(c#)

一 引用redis  (nuget   搜索:CSRedisCore)

二 使用redis(c#)

using System;

namespace ConsoleAppRedis
{
    class Program
    {
        static void Main(string[] args)
        {
            //第一种
            var rds = new CSRedis.CSRedisClient("127.0.0.1:6379");
            rds.Set("test1", "123123", 60);
            var str = rds.Get("test1");
            Console.WriteLine(str);


            //第二种
            RedisHelper.Initialization(rds);
            RedisHelper.Set("aaaa", 11111);
            var str1 = RedisHelper.Get("aaaa");
            Console.WriteLine(str1);

            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/ligenyun/p/10786483.html