C#操作Redis入门

作者: 张中华 | 来源:发表于2017-09-24 14:50 被阅读73次

1.新建控制台应用程序



2.引用以下四个类库


PM> install-package servicestack

3.获取所有的keys的demo
RedisHelper.cs

using ServiceStack.Redis;
using ServiceStack.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace RedisTestOne
{
    class RedisHelper
    {
        public static void GetAllKeys()
        {
            using (var client = new RedisClient("127.0.0.1",6379))
            {
                client.SetEntryInHash("Person:1", "name", "zzh");
                client.SetEntryInHash("Person:1", "sex", "男");
                List<string> allKeys = client.GetAllKeys();
                foreach(var key in allKeys)
                { 
                    Console.WriteLine(key);
                }
            }
        }
    }
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServiceStack.Redis;
using RedisTestOne;

namespace RedisTestOne
{
    class Program
    {
        static void Main(string[] args)
        {
            RedisHelper.GetAllKeys();
            Console.ReadLine();
        }
    }
}

相关文章

  • C#操作Redis入门

    1.新建控制台应用程序 2.引用以下四个类库 3.获取所有的keys的demoRedisHelper.cs Pro...

  • redis入门与操作

    redis入门与操作 运行:redis-server 连接客户端:redis-cli redis 是key-val...

  • 10.Redis编程入门

    本主题主要是Redis的基本入门,包含内容:  1. Redis的安装与配置  2.Redis的命令行操作  3....

  • 如何在 Windows 上安装 MongoDB

    MongoDB C# Driver 管理快速入门指南MongoDB C# Driver 快速入门指南Windows...

  • Redis C# Driver - StackExchange.

    Redis C# Driver StackExchange.Redis StackOverflow 出品 Serv...

  • C#/.Net学习资料

    C#开发轻松入门——基础入门(慕课网) 零基础学C#(一)——基础入门(网易云课堂明日科技) 45分钟C#快速入门...

  • 华为云学院带你7天入门Redis(4)

    华为云学院带你7天入门Redis(4) Redis实例配置参数 1、操作场景和限制介绍 什么是数据结构? 1.基于...

  • 一些挺不错的博客/学习网址

    Redis学习: 官方文档:redis中文网 基本入门:Redis入门视频教程-慕课网、Redis 教程 | 菜鸟...

  • C#/.net学习资料

    C#开发轻松入门——新手基础入门(慕课网) 零基础学C#(一)——新手基础入门(网易云课堂明日科技) 45分钟C#...

  • Redis(一)初识Redis

    本文主要包括 NoSQL入门、Redis环境搭建和Redis入门三个部分。 一 、NoSQL入门 NoSQL(no...

网友评论

    本文标题:C#操作Redis入门

    本文链接:https://www.haomeiwen.com/subject/pnskextx.html