redis 快速入门(win7)

0:介绍 百度百科or官网

1:下载  选择32位或者64

地址:https://github.com/dmajkic/redis/downloads

1.1下载后如图 

1.2文件介绍

redis-server.exe:服务程序  
redis-check-dump.exe:本地数据库检查 
redis-check-aof.exe:更新日志检查 
redis-benchmark.exe:性能测试,用以模拟同时由N个客户端发送M个 SETs/GETs 查询.
redis-cli.exe: 服务端开启后,我们的客户端就可以输入各种命令测试了 

2:安装 

2.1盘新建目录 名称 redis(任意取 只要符合windows命名要求就ok)

2.2 将下载的32bit复制到新建redis目录下(2.1、2.2 可以合并 看个人习惯)

3启动redis服务

1:启动 cmd  win+r 
1.1 d:
1.2 cd redis
1.3 redis-server.exe redis.conf 

 

默认端口 6379 redis

此时redis 启动成功

4:1-3是以cmd窗口方式  在正式使用明显不合理 我们希望以windows服务的网上安装

4.1地址 https://github.com/rgl/redis/downloads

4.2安装后  windows服务里面就能找到 

5 c# code 操作 redis

装备工作 vs10 redis dll

code demo:

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

namespace redisDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //建立socket连接 指定redis 安装的ip 和端口 6379 是默认
            var client = new RedisClient("127.0.0.1", 6379);

            //设置值
            client.Set<string>("userName", "lsw");

            //取值
            var getUserName1 = client.Get<string>("userName");

            Console.WriteLine(getUserName1);


            //设置值2(重复的key redis 覆盖值)
            client.Set<string>("userName", "lsw2");

            //取值
            var getUserName2 = client.Get<string>("userName");

            Console.WriteLine(getUserName2);


            //hash (适合存对象)
            client.SetEntryInHash("js", "name", "AngularJS");
            client.SetEntryInHash("js", "name1", "node");
            client.SetEntryInHash("js", "name2", "React");
            var key = client.GetHashKeys("js");
            var value = client.GetHashValues("js");


            // 若存在,则删除
            if (client.Exists("cs") > 0)
            {
                client.Del("cs");
            }
            //队列  先进先出
            client.EnqueueItemOnList("cs", "hello");//入队。
            client.EnqueueItemOnList("cs", "world");
            int length = client.GetListCount("cs");
            for (int i = 0; i < length; i++)
            {
                Console.WriteLine(client.DequeueItemFromList("cs"));//出队.
            }

            if (client.Exists("demo") > 0)
            {
                client.Del("demo");
            }
            //入栈 先进后出
            client.PushItemToList("demo", "hello");
            client.PushItemToList("demo", "world");
            int temp = client.GetListCount("demo");
            for (int i = 0; i < temp; i++)
            {
                Console.WriteLine(client.PopItemFromList("demo"));//出栈.
            }

            //set 并集,交集,差集.
            client.AddItemToSet("demo", "a");
            client.AddItemToSet("demo", "e");
            client.AddItemToSet("demo", "c");
            client.AddItemToSet("demo", "d");
            client.AddItemToSet("cs", "e");
            client.AddItemToSet("cs", "f");
            client.AddItemToSet("cs", "f");

            HashSet<string> hashset = client.GetAllItemsFromSet("demo");
            foreach (string str in hashset)
            {
                Console.WriteLine(str);
            }

            //求交集
            HashSet<string> jj = client.GetIntersectFromSets(new string[] { "demo", "cs" });
            //求差集.
            HashSet<string> bj = client.GetDifferencesFromSet("demo", new string[] { "cs" });

            Console.ReadKey();
        }
    }
}

5: redis 主从复制 、其他?? 

5.1 I don't know, I'm in my study.

 redis 客户端可视化工具下载:

https://redisdesktop.com/download

原文地址:https://www.cnblogs.com/y112102/p/4632272.html