zoukankan      html  css  js  c++  java
  • Redis在C#控制台程序的初次使用

    在上一篇文章中,https://www.cnblogs.com/Vinkong/p/11649101.html

    client四个引用
    ServiceStack.Common.dll
    ServiceStack.Interfaces.dll
    ServiceStack.Redis.dll
    ServiceStack.Text.dll
    也可以使用这个三个引用
    ServiceStack.dll
    ServiceStack.Interfaces.dll
    ServiceStack.ServiceInferface.dll
    

    了解了redis的具体使用场景,也已经成功安装了redis,并成功启动了redis服务端,测试了基本的操作。

    接下来在C#控制台程序怎么使用redis呢

    上面提供了两套dll下载,我是通过看到有人都用过所以都测试了一下,具体区别我也不是很清楚。

    地址:

    链接: https://pan.baidu.com/s/13cbYSLyjiC6_M4s6wQxyxQ 提取码: kc9u

    新建C#控制台应用程序,添加引用

    using ServiceStack.Redis;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static RedisClient redisClient = new RedisClient("127.0.0.1", 6379); // 设置Redis服务IP和端口
    
            static void Main(string[] args)
            {
                redisClient.Set("MyName", "Vinkong"); // 设置key为MyName的值
                Console.WriteLine(redisClient.Get<string>("MyName"));
                Console.Read();
            }
        }
    }

      

  • 相关阅读:
    《架构之美》读后感(二)
    《架构之美》读后感(一)
    《代码大全2》阅读笔记03
    《代码大全2》阅读笔记02
    《代码大全2》阅读笔记01
    学习进度报告(十四)
    软件方法阅读笔记03
    第二讲
    1.26 十讲第一讲
    1.23
  • 原文地址:https://www.cnblogs.com/Vinkong/p/12653204.html
Copyright © 2011-2022 走看看