Redis学习(1)——下载与配置[转]
Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。从2010年3月15日起,Redis的开发工作由VMware主持。
1、下载https://github.com/dmajkic/redis/downloads;由于我电脑是win7 64bit 所以下载
redis-2.4.5-win32-win64.zip — Redis-2.4.5 - Windows binaries (win32 and x64 included)
2、压缩包下载后,我解压到桌面上,看到32bit和64bit两个文件夹,我只是用64bit那个,主要的文件如下
redis-server.exe:服务程序
redis-check-dump.exe:本地数据库检查
redis-check-aof.exe:更新日志检查
redis-benchmark.exe:性能测试,用以模拟同时由N个客户端发送M个 SETs/GETs 查询 (类似于 Apache 的ab 工具).
redis-cli.exe 客户端,访问服务程序的节点
3、体验
(1)启动服务端
[4392] 01 Apr 13:27:59 * Server started, Redis version 2.4.5
[4392] 01 Apr 13:27:59 # Open data file dump.rdb: No such file or directory
[4392] 01 Apr 13:27:59 * The server is now ready to accept connections on port 6379 //服务端的端口
[4392] 01 Apr 13:28:00 - 0 clients connected (0 slaves), 1179896 bytes in use //显示连接服务端的客户端数量
[4392] 01 Apr 13:28:06 - 0 clients connected (0 slaves), 1179896 bytes in use
[4392] 01 Apr 13:28:11 - 0 clients connected (0 slaves), 1179896 bytes in use
[4392] 01 Apr 13:28:17 - 0 clients connected (0 slaves), 1179896 bytes in use
(2)启动客户端
C:\Users\Administrator\Desktop\Redis\redis-2.4.5-win32-win64\64bit>redis-cli.exe -h localhost -p 6379 //localhost可以换为服务器的IP地址,127.0.0.1
(3)操作
redis localhost:6379> set wil "Niu"
OK
redis localhost:6379> get wil
"Niu"
redis localhost:6379> lpush "Be"
(error) ERR wrong number of arguments for 'lpush' command
redis localhost:6379> lpush friends "be"
(integer) 1
redis localhost:6379> get wil
"Niu"
redis localhost:6379> lrange friends 0 -1
1) "be"
redis localhost:6379> lrange friends 0 -2
(empty list or set)
redis localhost:6379> lrange friends get friends
1) "be"
redis localhost:6379> exists wil
(integer) 1
redis localhost:6379>
……