redis 快速入门(win7)
2024-10-19 22:17:31
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服务
:启动 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", ); //设置值
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") > )
{
client.Del("cs");
}
//队列 先进先出
client.EnqueueItemOnList("cs", "hello");//入队。
client.EnqueueItemOnList("cs", "world");
int length = client.GetListCount("cs");
for (int i = ; i < length; i++)
{
Console.WriteLine(client.DequeueItemFromList("cs"));//出队.
} if (client.Exists("demo") > )
{
client.Del("demo");
}
//入栈 先进后出
client.PushItemToList("demo", "hello");
client.PushItemToList("demo", "world");
int temp = client.GetListCount("demo");
for (int i = ; 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
最新文章
- 前端开发:Javascript中的数组,常用方法解析
- WPF中获取鼠标相对于桌面位置
- windows下修复Linux引导 and linux下几个常用软件
- Linux 命令行快捷键
- UML系列05之 基本流程图
- 用类求圆面积c++
- 获取SqlDataReader的列名
- group by调优的一些测试
- BZOJ 1051: [HAOI2006]受欢迎的牛 缩点
- 自动化测试实施的几个idea
- Jquery对回复者添加匿名评论选项
- mysql源码安装(5.1)
- JavaScript调试技巧
- OKMX6Q LTIB编译
- yum 出问题了
- AI应用开发实战 - 手写识别应用入门
- 【.NET】 C# 时间戳和DataTime 互相转换
- mysql 聚集函数 count 使用详解(转载)
- c# 接口的协变和逆变
- dp的斜率优化