Redis菜鳥(niǎo)教程(一)

1下載安裝后啟動(dòng)客戶端調(diào)試:

cd到安裝路徑

cd C:\Program Files\Redis

redis-cli.exe -h 127.0.0.1 -p 6379

密碼修改:修改配置文件“redis.windows-service.conf

################################## SECURITY ##################

# Require clients to issue AUTH <PASSWORD> before processing any other

# commands. This might be useful in environments in which you do not trust

# others with access to the host running redis-server.

#

# This should stay commented out for backward compatibility and because most

# people do not need auth (e.g. they run their own servers).

#

# Warning: since Redis is pretty fast an outside user can try up to

# 150k passwords per second against a good box. This means that you should

# use a very strong password otherwise it will be very easy to break.

#

# requirepass foobared

requirepass 密碼

修改新密碼需要重啟服務(wù),認(rèn)證密碼

C:\Program Files\Redis>redis-server --service-start

[15236] 17 Mar 08:40:19.111 # Redis service successfully started.

C:\Program Files\Redis>redis-cli.exe -h 127.0.0.1 -p 6379

127.0.0.1:6379> keys *

(error) NOAUTH Authentication required.

127.0.0.1:6379> auth food

OK -------------認(rèn)證成功

2查看所有key

查看所有key

3判斷 key的類型

image.png

4 string 類型數(shù)據(jù)

1) 設(shè)置值set ,取值get

image.png
  1. 修改key的名字
image.png

3)刪除key

image.png

4) 查看key是否存在

image.png

5)設(shè)置key的過(guò)期時(shí)間,以秒計(jì)算 EXPIRE KEY Second

image.png

6)以秒為單位,返回給定 key 的剩余生存時(shí)間(TTL, time to live)。

PTTL key以毫秒為單位返回 key 的剩余的過(guò)期時(shí)間

image.png

5 LIST列表數(shù)據(jù)類型

6 哈希數(shù)據(jù)

6.1 HGETALL key 獲取在哈希表中指定 key 的所有字段和值

image.png

6.2 HSET key field value 將哈希表 key 中的字段 field 的值設(shè)為 value 。

6.3 設(shè)置哈希的過(guò)期時(shí)間

image.png
image.png

哈希 key 設(shè)置過(guò)期時(shí)間后,若哈希值由更改,過(guò)期時(shí)間原先設(shè)置的剩余過(guò)期時(shí)間不變。若想改變過(guò)期時(shí)間,需要重新設(shè)置。key過(guò)期后,Redis中將key自動(dòng)從Redis數(shù)據(jù)庫(kù)中刪除。若想繼續(xù)使用,可以重新創(chuàng)建。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容