redis 基本命令

2021-08-09 10:44:58 字數 1195 閱讀 8230

1

del key

該命令用於在 key

存在時刪除

key。

dump key

序列化給定 key

,並返回被序列化的值。

exists key

檢查給定 key

是否存在。

expire key

seconds

為給定 key

設定過期時間。

expireat key timestamp

expireat 的作用和

expire

類似,都用於為

key

設定過期時間。 不同在於

expireat

命令接受的時間引數是

unix

時間戳(unix timestamp)。

pexpire key milliseconds

設定 key

的過期時間以毫秒計。

pexpireat key milliseconds-timestamp

設定 key

過期時間的時間戳

(unix timestamp)

以毫秒計

keys pattern

查詢所有符合給定模式( pattern)

的 key 。

move key db

將當前資料庫的 key

移動到給定的資料庫

db 當中。

persist key

移除 key

的過期時間,

key

將持久保持。

pttl key

以毫秒為單位返回 key

的剩餘的過期時間。

ttl key

以秒為單位,返回給定 key

的剩餘生存時間

(ttl, time to live)。

randomkey

從當前資料庫中隨機返回乙個 key 。

rename key newkey

修改 key

的名稱

renamenx key newkey

僅當 newkey

不存在時,將

key

改名為

newkey 。

type key

返回 key

所儲存的值的型別。

redis基本命令

一,基本操作 1.select index index 0 idnex 17選擇資料庫 3.shutdown 停止資料庫 4.config get loglevel 得到當前日誌級別 5.flushall 清空所有資料庫的資料 6.keys 遍歷當前資料庫中所有的鍵 7.type key 獲取鍵的型...

redis基本命令

redis是乙個記憶體資料庫,通常可以作為快取使用,常用的命令有 redis server 啟動資料庫,預設埠為6379 redis cli 連線資料庫,預設ip是127.0.0.1,埠是6379 redis cli h 127.0.0.1 p 6380 a 密碼 連線資料庫,指定主機和埠號 sel...

Redis 基本命令

dir usr local redis redis 2.8.13 start sever cd dir src redis server src redis cli stop server pkill redis server commands keys 將redis 作為linux 服務隨機啟動 ...