bit

英[b?t]? ?美[b?t]??

n.一點,一塊;少量,少許;一會兒,一轉(zhuǎn)眼;[計] 位元(二進位制資訊單位)

adj.很小的,微不足道的

adv.[口語]相當,有點兒,或多或少,多少[a bit to的省略]

vt.給(馬)上嚼子;上銜鐵;抑制;制約

v.咬,叮( bite的過去式);刺痛;咬餌;有咬(或叮)的習性

第三人稱單數(shù): bits 複數(shù): bits 現(xiàn)在分詞: bitting 過去式: bitted 過去分詞: bitted

op

##n[?p ]? ?美[ɑ:p]??

n.工作,操作

#複數(shù): ops

redis BITOP指令 語法

作用:對一個或多個儲存二進位位元的字串?key?進行位元運算,並將結(jié)果儲存到?destkey?上。

語法:BITOP operation destkey key [key ...]

#說明:當?BITOP?處理不同長度的字串時,較短的那個字串所缺少的部分會被看作?0?。空的?key?也被視為包含?0?的字串序列。

可用版本:>= 2.6.0

#時間複雜度:O(N)

傳回:儲存到?destkey?的字串的長度,和輸入?key?中最長的字串長度都相等。

redis BITOP指令 範例

redis> SETBIT bits-1 0 1        # bits-1 = 1001
(integer) 0
redis> SETBIT bits-1 3 1
(integer) 0
redis> SETBIT bits-2 0 1        # bits-2 = 1011
(integer) 0
redis> SETBIT bits-2 1 1
(integer) 0
redis> SETBIT bits-2 3 1
(integer) 0
redis> BITOP AND and-result bits-1 bits-2
(integer) 1
redis> GETBIT and-result 0      # and-result = 1001
(integer) 1
redis> GETBIT and-result 1
(integer) 0
redis> GETBIT and-result 2
(integer) 0
redis> GETBIT and-result 3
(integer) 1