日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

Redis Windows环境安装

發布時間:2023/12/4 windows 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 == 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环境安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。