1. 程式人生 > >Redis學習(1)——下載與配置

Redis學習(1)——下載與配置

Redis是一個開源的使用ANSI C語言編寫、支援網路、可基於記憶體亦可持久化的日誌型、Key-Value資料庫,並提供多種語言的API。從2010年3月15日起,Redis的開發工作由VMware主持。

      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)啟動服務端

 C:\Users\Administrator\Desktop\Redis\redis-2.4.5-win32-win64\64bit>redis-server.exe redis.conf
[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>

……