Redis Windows环境安装
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环境安装的更多相关文章
- Redis windows环境安装 以及 redis整合spring
Redis对于Linux是官方支持的,安装和使用没有什么好说的,普通使用按照官方指导,5分钟以内就能搞定.详情请参考: http://redis.io/download Redis官方是不支持wind ...
- Redis——windows环境安装redis和redis sentinel部署
一:Redis的下载和安装 1:下载Redis Redis的官方网站Download页面,Redis提示说:Redis的正式版不支持Windows,要Windows学习Redis,请点击Learn m ...
- Redis:在windows环境安装Redis
Redis:在windows环境安装Redis 第一步: 下载windows版本的Redis:https://github.com/MSOpenTech/Redis. 第二步: 在命令行执行:D:\r ...
- PHP XAMPP windows环境安装扩展redis 致命错误: Class 'Redis' not found解决方法
PHP XAMPP windows环境安装扩展redis 致命错误: Class 'Redis' not found解决方法 1.电脑需要先安装redis服务端环境,并在安装目录下打开客户端redis ...
- Windows环境安装tesseract-ocr 4.00并配置环境变量
最近要做文字识别,不让直接用别人的接口,所以只能尝试去用开源的类库.tesseract-ocr是惠普公司开源的一个文字识别项目,通过它可以快速搭建图文识别系统,帮助我们开发出能识别图片的ocr系统.因 ...
- windows环境安装MySQL
转:https://www.cnblogs.com/ayyl/p/5978418.html windows环境安装MySQL mySQL下载链接:MySQL Installer 5.7 :http:/ ...
- Windows环境安装MySQL数据库
Windows环境安装MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 最近在学习Java语言,开发环境在Windows操作系统上,因此需要在Windows上安装My ...
- MongoDB(二):在Windows环境安装MongoDB
1. 在Windows环境安装 1.1 MongoDB下载 要在Windows上安装MongoDB,首先打开MongoDB官网:https://www.mongodb.com/download-cen ...
- window安装reidis完成之后,想要把数据存入redis,必须开扩展,不然报错,redis windows phpstudy 安装扩展
redis windows phpstudy 安装扩展 1.http://windows.php.net/downloads/pecl/releases/redis/3.1.5rc1/ 2.htt ...
随机推荐
- Rails 5 Test Prescriptions 第4章 什么制造了伟大的测试
伴随着程序成长,测试变长,复杂性增加,如何更高效的写测试,对以后开发不会造成麻烦. 测试本身没发被测试,所以一定要清楚,可控.不要加循环,不要过于复杂的自动编程. Cost and Value 成本和 ...
- RabbitMQ的几种工作模式
maven: <dependencies> <!-- RabbitMQ的客户端 --> <dependency> <groupId>com.rabbit ...
- maven打包资源文件(转)
原文链接:http://blog.csdn.net/u012849872/article/details/51035938 maven工程标准目录结构: src -main –bin ...
- Centos7 安装JDK环境和Tomcat
Linux JDK 64位下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.ht ...
- 量化投资策略:常见的几种Python回测框架(库)
量化投资策略:常见的几种Python回测框架(库) 原文地址:http://blog.csdn.net/lawme/article/details/51454237 本文章为转载文章.这段时间在研究量 ...
- Ubuntu tar方式安装mysql5.7.21 时报错 [ERROR] Can't locate the language directory. 以及 ------ libaio.so.1: cannot open shared object file
参考帖子: http://blog.csdn.net/ty0415/article/details/22958133 首先,在 MySQL 官方网站上下载安装包, 如图: 然后,执行安装命令 bin/ ...
- 替换国内yum源以及pip源
因为一些原因,不论是网络还是啥啥啥的原因,国外的源访问时不时的很慢,这时候我们就可以将国外的源替换为国内源,提高下载速度. yum源替换 环境:centos7(如果你的发行版本不是这个,此方法不保证能 ...
- jquery类的创建方式及关键字new的原理
一.由jQuery创建类引发的问题 在用jQuery选择器时候,可以通过下面两种方式获取元素,并得到一个jQuery对象. var d1 = jQuery('#demo01'); var d2 = n ...
- 写时复制和fork,vfork,clone
写时复制 原理: 用了“引用计数”,会有一个变量用于保存引用的数量.当第一个类构造时,string的构造函数会根据传入的参数从堆上分配内存,当有其它类需要这块内存时,这个计数为自动累加,当有类析构时, ...
- pthread线程私有数据
进程内所有的线程共享地址空间,任何声明为静态或外部的变量,或在进程堆声明的变量都可以被进程内的所有线程读写. static,extern,或堆变量的值是上次线程改写的值 一个线程真正拥有的唯一私有存储 ...