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 ...
随机推荐
- BooStrap4文档摘录 2 Content, Component
Content Reboot:从新写了主要元素的排列. 本章讲了各种元素及其相关的类. ⚠️ 文档左上角有搜索栏. Components Alert✅ Badge✅ Button✅和Button gr ...
- bzoj1143: [CTSC2008]祭祀river 最长反链
题意:在遥远的东方,有一个神秘的民族,自称Y族.他们世代居住在水面上,奉龙王为神.每逢重大庆典, Y族都会在水面上举办盛大的祭祀活动.我们可以把Y族居住地水系看成一个由岔口和河道组成的网络.每条河道连 ...
- Intellij Idea 将java项目打包成jar
1.菜单:File->project stucture 2.在弹窗最左侧选中Artifacts->"+",选jar,选择from modules with depend ...
- Android学习必备--java工具15个
Weka .Weka集成了数据挖掘工作的机器学习算法.这些算法可以直接应用于一个数据集上或者你可以自己编写代码来调用.Weka包括一系列的工具,如数据预处理.分类.回归.聚类.关联规则以及可视化. M ...
- 知识梳理——CSS篇
css引入方法 内嵌 <head> <meta charset="UTF-8"> <title>Document</title> & ...
- hdu 3262 09 宁波 现场 C - Seat taking up is tough 暴力 难度:0
Description Students often have problems taking up seats. When two students want the same seat, a qu ...
- cuteftp不能连接虚拟机的解决方法
使用cuteftp在PC和虚拟机之间传送文件 工具/原料 PC机中装有cuteftp软件和虚拟机 注意事项 首先要确保虚拟机中的ftp软件已安装,如未安装可以用如下命令安装 sudo apt-get ...
- Codeforces 148B: Escape
题目链接:http://codeforces.com/problemset/problem/148/B 题意:公主从龙的洞穴中逃跑,公主的速度为vp,龙的速度为vd,在公主逃跑时间t时,龙发现公主逃跑 ...
- HDU4261 Estimation
题意 Estimation Time Limit: 40000/15000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- c++交叉#include问题
这个问题会引起莫名其妙的编译错误, 碰到类里有其他类的指针的话,不要#include,提前声明下即可 class_a.h #ifndef CLASS_A_H #define CLASS_A_H cla ...