?
This document uses PHP Chinese website manual Release
CLUSTER SLOTS
自3.0.0起可用。
時間復(fù)雜度: O(N)其中N是 Cluster 節(jié)點(diǎn)的總數(shù)
CLUSTER SLOTS 返回有關(guān)哪些集群插槽映射到哪些 Redis 實(shí)例的詳細(xì)信息。該命令適合由 Redis Cluster 客戶端庫實(shí)現(xiàn)使用,以便檢索(或在接收到重定向時更新)將簇哈希槽與實(shí)際節(jié)點(diǎn)網(wǎng)絡(luò)坐標(biāo)關(guān)聯(lián)的映射(由IP地址和TCP端口組成),因此當(dāng)收到一個命令時,它可以發(fā)送到命令中指定的密鑰的正確實(shí)例。
每個嵌套結(jié)果是:
開始插槽范圍
結(jié)束插槽范圍
主插槽范圍表示為嵌套 IP /端口陣列
插槽范圍的主復(fù)制品的第一個副本
第二個副本
...繼續(xù),直到返回此主設(shè)備的所有副本。
每個結(jié)果都包括所列槽位范圍的主實(shí)例的所有活動副本。失敗的副本不會返回。
第三個嵌套答復(fù)保證是插槽范圍的主實(shí)例的 IP /端口對。第三個嵌套回復(fù)后的所有 IP /端口對都是主設(shè)備的復(fù)制品。
如果群集實(shí)例具有非連續(xù)的插槽(例如1-400,900,1800-6000),則主副本 IP /端口結(jié)果將針對每個頂級插槽范圍答復(fù)進(jìn)行復(fù)制。
警告:對于每個 Redis 實(shí)例,較新版本的 Redis 群集將輸出不僅僅是 IP 和端口,而且還會將節(jié)點(diǎn) ID 作為陣列的第三個元素輸出。在未來的版本中,可能會有更多元素更好地描述節(jié)點(diǎn)。一般來說,客戶端實(shí)現(xiàn)應(yīng)該僅僅依賴于某些參數(shù)處于指定位置的固定位置這一事實(shí),但更多的參數(shù)可能隨之而來,應(yīng)該被忽略。同樣,客戶端庫應(yīng)盡可能地嘗試處理舊版本可能只有 IP 和端口參數(shù)的事實(shí)。
陣列回復(fù):帶有 IP /端口映射的插槽范圍的嵌套列表。
127.0.0.1:7001> cluster slots 1) 1) (integer) 0 2) (integer) 4095 3) 1) "127.0.0.1" 2) (integer) 7000 4) 1) "127.0.0.1" 2) (integer) 7004 2) 1) (integer) 12288 2) (integer) 16383 3) 1) "127.0.0.1" 2) (integer) 7003 4) 1) "127.0.0.1" 2) (integer) 7007 3) 1) (integer) 4096 2) (integer) 8191 3) 1) "127.0.0.1" 2) (integer) 7001 4) 1) "127.0.0.1" 2) (integer) 7005 4) 1) (integer) 8192 2) (integer) 12287 3) 1) "127.0.0.1" 2) (integer) 7002 4) 1) "127.0.0.1" 2) (integer) 7006
127.0.0.1:30001> cluster slots 1) 1) (integer) 0 2) (integer) 5460 3) 1) "127.0.0.1" 2) (integer) 30001 3) "09dbe9720cda62f7865eabc5fd8857c5d2678366" 4) 1) "127.0.0.1" 2) (integer) 30004 3) "821d8ca00d7ccf931ed3ffc7e3db0599d2271abf" 2) 1) (integer) 5461 2) (integer) 10922 3) 1) "127.0.0.1" 2) (integer) 30002 3) "c9d93d9f2c0c524ff34cc11838c2003d8c29e013" 4) 1) "127.0.0.1" 2) (integer) 30005 3) "faadb3eb99009de4ab72ad6b6ed87634c7ee410f" 3) 1) (integer) 10923 2) (integer) 16383 3) 1) "127.0.0.1" 2) (integer) 30003 3) "044ec91f325b7595e76dbcb18cc688b6a5b434a1" 4) 1) "127.0.0.1" 2) (integer) 30006 3) "58e6e48d41228013e5d9c1c37c5060693925e97e"