Redis最常用命令

啓動 Redis 服務
src/redis-server或者src/redis-server redis.conf

src/redis-server redis.conf 1>log.log 2>errlog.log

1爲標準輸出,2爲錯誤輸出

將 Redis 作爲 Linux 服務隨機啓動
vi /etc/rc.local, 加入代碼:

/root/install/redis-2.4.9/src/redis-server

客戶端連接
src/redis-cli

停止redis服務:
src/redis-cli shutdown

增刪改查:

keys *
取出當前匹配的所有key

> exists larry
(integer) 0

當前的key是否存在

del lv
刪除當前key

expire
設置過期時間

> expire larry 10
(integer) 1

> move larry ad4
(integer) 1

移動larry鍵值對到ad4數據庫

> persist lv
(integer) 1
移除當前key的過期時間

randomkey

隨機返回一個key

rename
重命名key

type
返回值的數據類型

 type testlist
list


> ping
PONG

測試連接是否還在

>echo name

"larry"

打印

> select ad4databank
OK
數據庫切換

> quit
退出連接

> dbsize
(integer) 12

當前數據庫中key的數量

> info
服務器基本信息

monitor

實時轉儲收到的請求

config get
獲取服務器的參數配置

flushdb
清空當前數據庫

flushall
清除所有數據庫


參考 : http://www.linuxidc.com/Linux/2012-03/57573.htm

發佈了326 篇原創文章 · 獲贊 28 · 訪問量 80萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章