Redis (Remote Dictionary Server) 是一個 open-source 的 in-memory 的資料儲存系統,分類上屬於 NoSQL。資料儲存在記憶體中所以速度可以很快,根據需求也可以支援寫入硬碟。不過最常用的功能是作為 cache。
下載 Python 套件
連線到 cloud Redis server
先到剛剛的連結點到你的 database 中的 Public Endpoint > Connect > 選擇 Python 後複製 code 連結
Python 連線 (password 這邊可以到 database 的 Security 欄位中使用預設的)
這邊加 decode_responses
可以讓之後查找時回傳已經 decode 的值
CRUD
Create: set
, Read: get
, Update: set
, Delete: delete
hset
, hget
, hdel
, …
針對 hash 值的 key/value 做操作,以下例子可以把 hash1
當作一個 table