1、下载Windows 版本 Redis:

https://github.com/ServiceStack/redis-windows

2、 解压文件:

F:\开源代码学习\01_Redis 打开 目录:F:\开源代码学习\01_Redis\src\msopentech\redis64-2.6.12.1

3、启动Redis

指向CMD命令:

4、测试安装成果:

新建一个CMD 窗口:

运行命令:

5、讲Redis 加工成 windows :

namespace RedisService
{/// <summary>/// 参考文档:/// http://www.saltwebsites.com/2012/how-run-redis-service-under-windows/// /// sc create Redis start= auto DisplayName= Redis binpath= "\"C:\Program Files\Redis\RedisService.exe\" \"C:\Program Files\Redis\redis.conf\""/// /// </summary>class Program : ServiceBase{const string RedisServer = "redis-server.exe";const string RedisCLI = "redis-cli.exe";static string _path;static int _port;static void Main(string[] args){_path = AppDomain.CurrentDomain.BaseDirectory;if (!File.Exists(Path.Combine(_path, RedisServer)))Exit("Couldn`t find " + RedisServer);if (!File.Exists(Path.Combine(_path, RedisCLI)))Exit("Couldn`t find " + RedisCLI);if (Environment.UserInteractive){SetConsoleCtrlHandler(ConsoleCtrlCheck, true);//Console.CancelKeyPress += (sender, eventArgs) => StopRedis();StartRedis(args.Length == 1 ? args[0] : null);}elseRun(new Program());}protected override void OnStart(string[] args){var arguments = Environment.GetCommandLineArgs();if (arguments.Length > 2)Exit("Too many arguments");base.OnStart(args);StartRedis(arguments.Length == 2 ? arguments[1] : null);}protected override void OnStop(){base.OnStop();StopRedis();}static void StartRedis(string configPath = null){var pi = new ProcessStartInfo(Path.Combine(_path, RedisServer));if (configPath != null){FindPort(configPath);// Workaround for spaces in configuration filename.pi.Arguments = Path.GetFileName(configPath);pi.WorkingDirectory = Path.GetDirectoryName(configPath);}using (var process = new Process { StartInfo = pi }){if (process.Start())if (Environment.UserInteractive)process.WaitForExit();else{}elseExit("Failed to start Redis process");}}private static void FindPort(string path){using (var reader = new StreamReader(path)){string line;while ((line = reader.ReadLine()) != null){if (line.IndexOf("port") == 0){_port = int.Parse(line.Substring(5, line.Length - 5));break;}}if (_port == 0)Exit("Couldn`t find Redis port in config file");}}static void StopRedis(){var pi = new ProcessStartInfo(Path.Combine(_path, RedisCLI)) { Arguments = (_port == 0 ? "" : String.Format("-p {0} ", _port)) + "shutdown" };if (!(new Process { StartInfo = pi }).Start())Exit("Failed to stop Redis process");}static void Exit(string message){if (Environment.UserInteractive){Console.WriteLine(message);Environment.Exit(-1);}else{//File.WriteAllText(Path.Combine(_path, "error.txt"), message);throw new ApplicationException(message);}}[DllImport("Kernel32")]private static extern bool SetConsoleCtrlHandler(HandlerRoutine handler, bool add);// A delegate type to be used as the handler routine // for SetConsoleCtrlHandler.private delegate bool HandlerRoutine(CtrlTypes ctrlType);// An enumerated type for the control messages// sent to the handler routine.private enum CtrlTypes{CTRL_C_EVENT = 0,CTRL_BREAK_EVENT,CTRL_CLOSE_EVENT,CTRL_LOGOFF_EVENT = 5,CTRL_SHUTDOWN_EVENT}private static bool ConsoleCtrlCheck(CtrlTypes ctrlType){StopRedis();return true;}}
}

Redis Windows环境安装相关推荐

  1. PHP XAMPP windows环境安装扩展redis 致命错误: Class ‘Redis‘ not found解决方法

    PHP XAMPP windows环境安装扩展redis 致命错误: Class 'Redis' not found解决方法 参考文章: (1)PHP XAMPP windows环境安装扩展redis ...

  2. Windows环境 安装dlib cv2(python) 总结

    文章来源于网络! window下查看1099端口被哪个进程占用的命令(window下命令也类&#20284;linux啊,netstat -aon|findstr "1099&quo ...

  3. Windows 环境安装 RabbitMQ

    下载 Erlang 安装包并安装 首先访问 https://www.erlang.org/downloads 下载 Erlang 环境的安装包,查看你的 Windows 环境的系统类型选择 32位或者 ...

  4. Windows环境安装MySQL步骤

    Windows环境安装MySQL步骤 前言 1.下载安装包 2.安装 3.工具连接 前言 说明:如果电脑上已经有MySQL数据库,就不用安装了,不管是Windows还是Linux或者Docker的,不 ...

  5. windows环境安装lzo和python-lzo

    windows环境安装lzo和python-lzo 概述 应用版本 Windows环境安装lzo 安装python-lzo插件 快速安装 代码示例 问题解析 近期因python项目开发中涉及到lzo文 ...

  6. Python3教程——1、Windows环境安装Python 3.8

    和小名一起学Python Python3教程--Windows环境安装Python 3.8  3.9 一.安装Python. 1.下载地址: https://www.python.org/downlo ...

  7. windows环境安装haproxy及初步配置负载均衡使用示例

    安装HaProxy 首先需要下载windows环境下需要文件,这里下载的是一个别人编译好的一个文件,这里省去了编译的过程,使用的版本是haproxy-1.7.8. 下载后直接解压到对应的目录下.示例( ...

  8. RabbitMQ简单介绍+Windows环境安装

    文章目录 文章目录 文章目录 1.RabbitMQ简介 2.RabbitMQ与其他MQ有什么不同 3.RabbitMQ环境安装 3.1 安装erlang 3.2 安装rabbitmq-server 4 ...

  9. R 语言 Windows 环境 安装与Windows下制作R的package--Rtools

    1.1    预装的软件 (所有软件都可以在 http://www.biosino.org/R/R-doc/Rm/ 和 http://www.biosino.org/R/requiredSoftWar ...

最新文章

  1. java 连接 MySQL
  2. OkHttp 使用基础
  3. 服务器怎样共享文件夹共享文件夹,服务器怎样共享文件夹共享文件夹
  4. 基类指针和子类指针相互赋值
  5. Cannot load 64-bit SWT libraries on 32-bit JVM 解决方法
  6. 【iOS】NSNotification 常用方法
  7. redis smembersmap_Redis五种数据类型
  8. 灵雀云 CTO 陈恺:从“鸿沟理论”看云原生,哪些技术能够跨越鸿沟?
  9. 电大计算机应用基础实训任务1-4,计算机应用基础本形考任务1
  10. [含lw+辩论PPT+任务书+中期检查表+源码等]基于ssm的NBA球队|篮球管理系统[包运行成功]
  11. ChinaITLab-Linux工程师培训课程笔记2
  12. 喀秋莎Camtasia Studio微视频录制工具使用指南
  13. 使用FFmpeg视频缩略图实现
  14. 智慧屏如何连接电视盒子
  15. 告诉你一个真实的Google
  16. 前端页面如何获取高德地图
  17. 孝感市小学生机器人编程比赛_小学生获机器人大赛一等奖 编程是语文老师教的...
  18. 数据结构——图(存储结构)
  19. PAT_乙级_1006_筱筱
  20. Flash鼠绘马蹄莲教程

热门文章

  1. 博鳌直击 | 区块链在互联网金融中扮演怎样的角色?
  2. 条件注释判断浏览器版本!--[if lt IE 9](转载)
  3. 自动性能统计信息(三)(Automatic Performance Statistics)
  4. ie8下修改input的type属性报错
  5. 10月Web服务器调查:Apache下降 Ngnix攀升
  6. JQuery 1.6+ checkbox 状态选择
  7. 帆软报表(finereport)table块钻取,返回记住table块位置
  8. (一)使用appium之前为什么要安装nodejs???
  9. 类属性和实例属性冲突
  10. Delphi全局热键的注册