## 安裝 Redis Redis 是一種快速、開放原始碼的記憶體內鍵值資料結構存放區,可直接用apt安裝. Redis 資料庫伺服器套件已經被收錄在 Ubuntu Linux 的官方套件庫中,在 Ubuntu Linux 中可以直接使用 apt 安裝: ### 更新系統套件 sudo apt update ### 安裝 Redis 資料庫伺服器 sudo apt install redis-server 開啟 /etc/redis/redis.conf 設定檔, 設定由 systemd管理 ``` 在 /etc/redis/redis.conf 中新增 supervised systemd ``` ### 啟動 Redis 資料庫服務 sudo systemctl start redis.service ### 重新啟動 Redis 資料庫服務 sudo systemctl restart redis.service ### 查看 Redis 資料庫服務狀態 systemctl status redis.service ### 停止 Redis 資料庫服務 sudo systemctl stop redis.service ### 開機自動啟動 Redis 資料庫服務 sudo systemctl enable redis.service ### 取消開機自動啟動 Redis 資料庫服務 sudo systemctl disable redis.service ## 測試 Redis 資料庫 ``` rediscli 127.0.0.1:6379> ``` 命令查詢 http://doc.redisfans.com/ ## Redis 資料類型 Redis支援五種資料類型:string(字串),hash(雜湊),list(列表),set(集合)及zset(sorted set:有序集合)。 使用教學請參考 https://www.runoob.com/redis/redis-tutorial.html