Redis之基礎知識

2020-10-25 15:01:13

Redis是非關係型資料庫,即Not-Only SQL。通常應用於快取、Session共用和歷史資料處理等。Redis基於C語言研發,通過鍵值對儲存,可以承載巨量資料的高負載查詢。

  1. 資料庫高並行讀寫,即High Performance RW
  2. 海量資料的高效率查詢和儲存,即Huge Storage
  3. 高可用性、擴充套件性和易於整合,即High avaliability、scalability、Integration

Redis的資料型別

序號Type型別
1String字串
2Hash雜湊型別
3List列表型別
4Set集合型別
5Zset有序集合型別

Redis啟動

.\redis-server.exe .\redis.windows.conf
[27344] 23 Oct 12:16:44.973 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
[27344] 23 Oct 12:16:44.974 # Redis version=5.0.9, bits=64, commit=9414ab9b, modified=0, pid=27344, just started
[27344] 23 Oct 12:16:44.974 # Configuration loaded

Redis停止

 .\redis-cli.exe shutdown
 [20364] 23 Oct 12:45:18.515 # Redis is now ready to exit, bye bye...

使用者端連線伺服器,輸入並顯示

 .\redis-cli.exe -h 127.0.0.1 -p 6379
 127.0.0.1:6379> set mykey myvalue
 127.0.0.1:6379> get mykey
"myvalue"

以下把Redis製作成Windows的服務,方便使用

設定Windows的Redis服務

redis-server --service-install redis.windows.conf --loglevel verbose
[31104] 23 Oct 18:03:32.939 # Granting read/write access to 'NT AUTHORITY\NetworkService' on: "D:\Redis-x64-5.0.9" 
[31104] 23 Oct 18:03:32.941 # Redis successfully installed as a service.

Windows服務Services.msc中生成Redis服務
D:\Redis-x64-5.0.9\redis-server.exe" --service-run redis.windows.conf --loglevel verbose

啟動windows的Redis服務

 redis-server --service-start
 [32424] 23 Oct 18:12:50.754 # Redis service successfully started.

停止windows的Redis服務

 redis-server --service-stop
 [33536] 23 Oct 18:15:29.446 # Redis service successfully stopped.

解除安裝windows的Redis服務

 .\redis-server.exe --service-uninstall
 [27124] 23 Oct 18:01:02.657 # Redis service successfully uninstalled.