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 == ? args[] : null);
}
else
Run(new Program());
} protected override void OnStart(string[] args)
{
var arguments = Environment.GetCommandLineArgs();
if (arguments.Length > )
Exit("Too many arguments");
base.OnStart(args);
StartRedis(arguments.Length == ? arguments[] : 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
{
}
else
Exit("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") == )
{
_port = int.Parse(line.Substring(, line.Length - ));
break;
}
}
if (_port == )
Exit("Couldn`t find Redis port in config file");
}
} static void StopRedis()
{
var pi = new ProcessStartInfo(Path.Combine(_path, RedisCLI)) { Arguments = (_port == ? "" : 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(-);
}
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 = ,
CTRL_BREAK_EVENT,
CTRL_CLOSE_EVENT,
CTRL_LOGOFF_EVENT = ,
CTRL_SHUTDOWN_EVENT
} private static bool ConsoleCtrlCheck(CtrlTypes ctrlType)
{
StopRedis();
return true;
}
}
}

Redis Windows环境安装的更多相关文章

  1. Redis windows环境安装 以及 redis整合spring

    Redis对于Linux是官方支持的,安装和使用没有什么好说的,普通使用按照官方指导,5分钟以内就能搞定.详情请参考: http://redis.io/download Redis官方是不支持wind ...

  2. Redis——windows环境安装redis和redis sentinel部署

    一:Redis的下载和安装 1:下载Redis Redis的官方网站Download页面,Redis提示说:Redis的正式版不支持Windows,要Windows学习Redis,请点击Learn m ...

  3. Redis:在windows环境安装Redis

    Redis:在windows环境安装Redis 第一步: 下载windows版本的Redis:https://github.com/MSOpenTech/Redis. 第二步: 在命令行执行:D:\r ...

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

    PHP XAMPP windows环境安装扩展redis 致命错误: Class 'Redis' not found解决方法 1.电脑需要先安装redis服务端环境,并在安装目录下打开客户端redis ...

  5. Windows环境安装tesseract-ocr 4.00并配置环境变量

    最近要做文字识别,不让直接用别人的接口,所以只能尝试去用开源的类库.tesseract-ocr是惠普公司开源的一个文字识别项目,通过它可以快速搭建图文识别系统,帮助我们开发出能识别图片的ocr系统.因 ...

  6. windows环境安装MySQL

    转:https://www.cnblogs.com/ayyl/p/5978418.html windows环境安装MySQL mySQL下载链接:MySQL Installer 5.7 :http:/ ...

  7. Windows环境安装MySQL数据库

    Windows环境安装MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 最近在学习Java语言,开发环境在Windows操作系统上,因此需要在Windows上安装My ...

  8. MongoDB(二):在Windows环境安装MongoDB

    1. 在Windows环境安装 1.1 MongoDB下载 要在Windows上安装MongoDB,首先打开MongoDB官网:https://www.mongodb.com/download-cen ...

  9. window安装reidis完成之后,想要把数据存入redis,必须开扩展,不然报错,redis windows phpstudy 安装扩展

    redis windows phpstudy 安装扩展   1.http://windows.php.net/downloads/pecl/releases/redis/3.1.5rc1/ 2.htt ...

随机推荐

  1. sqlserver存储过程分页

    create  procedure [dbo].[SqlPager]@sqlstr nvarchar(4000), --查询字符串@currentpage int, --第N页@pagesize in ...

  2. 关于浏览器的eventflow(capture and bubble up)

    因为,没有全面的学习javascript,及其事件原理: 全占的课程:4-5 浏览器 Bubble Up 事件模型中 不是很理解它所讲的.网上查找相关知识点.记录中在博客中: 理解了JS的加载 htt ...

  3. Rails 5 Test Prescriptions 第8章 Integration Testing with Capybara and Cucumber

    Capybara:  A complete reference is available atrubydoc.info. 集成测试就是把局部的程序组合起来测试. 端到端测试是一个特殊的集成测试,覆盖了 ...

  4. RPC框架实践之:Apache Thrift

    一.概述 RPC(Remote Procedure Call)即 远程过程调用,说的这么抽象,其实简化理解就是一个节点如何请求另一节点所提供的服务.在文章 微服务调用链追踪中心搭建 一文中模拟出来的调 ...

  5. 过滤器系列(一)—— Bloom filter

    因为要做过滤器相关内容,最近读了一些过滤器方面的文章,准备从中提取主要思想写几篇博客. 作为这系列的第一篇文章,首先得讲一下过滤器是干什么用的.从历史发展来看,过滤器最早出现是作为散列表的替代品,那么 ...

  6. iOS UI-线程(NSThread)及其安全隐患与通信

    一.基本使用 1.多线程的优缺点 多线程的优点 能适当提高程序的执行效率 能适当提高资源利用率(CPU.内存利用率) 多线程的缺点 开启线程需要占用一定的内存空间(默认情况下,主线程占用1M,子线程占 ...

  7. 模板方法模式templeteMethod

    引出模板模式: 考试试卷问题,提炼后的代码: package com.disign.templetemethod; import org.junit.Test; /** * Created by zh ...

  8. ubuntu16.04下安装opencv3.3

    最近重装了ubuntu16.04的系统,在给电脑配置好cuda8.0和cudnn6.0的版本后,开始重新安装opencv,在opencv的官网上发现最新版本3.3版本增加了很多深度学习方面的东西,果断 ...

  9. HDU3488Tour (KM算法)

    题意:   有N个点,M个单向边,现在要你设计N条路线覆盖所有的点,每个点都属于且值属于一个环.(为什么是N条边:和最小生成树为什么有N-1条边是一样的证明). 解析:  每个点都有一个喜欢对象(出度 ...

  10. C# 根据twitter的snowflake算法生成唯一ID

    C# 版算法: using System; using System.Collections.Generic; using System.Linq; using System.Text; using ...