Redis作为一款NoSQL的热门分布式数据库,同时也是一款热门的分布式缓存,作为广大的Windows用户们,我们如何安装呢?很遗憾,它没有Windows版本。但有一群人自己鼓捣了一个Windows平台的redis,虽然目前已经3年没有更新,我们也只能将就着用了。https://github.com/MicrosoftArchive/redis是它的github地址,最新版本是3.2.100,进入到发布目录下https://github.com/MicrosoftArchive/redis/releases -> 点开Assets -> 下载Redis-x64-3.2.100.zip -> 解压后打开管理员命令行,进入到解压目录执行启动命令(我本地是D盘Dev目录):
C:WINDOWSsystem32>D: D:>cd DevRedis-x64-3.2.100 D:DevRedis-x64-3.2.100>redis-server.exe redis.windows.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.2.100 (00000000/0) 64 bit .-`` .-```. ```/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 28448 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [28448] 27 Apr 16:20:36.742 # Server started, Redis version 3.2.100 [28448] 27 Apr 16:20:36.745 * The server is now ready to accept connections on port 6379 [28448] 27 Apr 16:35:37.063 * 1 changes in 900 seconds. Saving... [28448] 27 Apr 16:35:37.080 * Background saving started by pid 36132 [28448] 27 Apr 16:35:37.280 # fork operation complete [28448] 27 Apr 16:35:37.281 * Background saving terminated with success
在解压目录下双击redis-cli.exe就可以通过客户端连接服务端进行操作了,这个客户端很有意思,它会根据你的命令提示你接下来的输出,你通过空格跳到对应的格式输入即可:
127.0.0.1:6379> hmset key field value [field value ...] 127.0.0.1:6379> hmset myKey1 name wulinfeng age 8 job codefarmer salary 100 OK 127.0.0.1:6379> hmget myKey1 name age job salary 1) "wulinfeng" 2) "8" 3) "codefarmer" 4) "100" 127.0.0.1:6379>
如果你想将redis加入到本地服务自启动,只需在命令行界面的redis解压目录下执行如下命令即可:
redis-server --service-install redis.windows.conf