bit
英[b?t]? ?美[b?t]??
n.一點(diǎn),一塊;少量,少許;一會(huì)兒,一轉(zhuǎn)眼;[計(jì)] 位元(二進(jìn)位制資訊單位)
adj.很小的,微不足道的
adv.[口語]相當(dāng),有點(diǎn)兒,或多或少,多少[a bit to的省略]
vt.給(馬)上嚼子;上銜鐵;抑制;制約
v.咬,叮( bite的過去式);刺痛;咬餌;有咬(或叮)的習(xí)性
第三人稱單數(shù): bits 複數(shù): bits 現(xiàn)在分詞: bitting 過去式: bitted 過去分詞: bitted
op
##n[?p ]? ?美[ɑ:p]??n.工作,操作#複數(shù): ops
redis BITOP指令 語法
作用:對(duì)一個(gè)或多個(gè)儲(chǔ)存二進(jìn)位位元的字串?key?進(jìn)行位元運(yùn)算,並將結(jié)果儲(chǔ)存到?destkey?上。
語法:BITOP operation destkey key [key ...]
#說明:當(dāng)?BITOP?處理不同長(zhǎng)度的字串時(shí),較短的那個(gè)字串所缺少的部分會(huì)被看作?0?。空的?key?也被視為包含?0?的字串序列。
可用版本:>= 2.6.0
#時(shí)間複雜度:O(N)
傳回:儲(chǔ)存到?destkey?的字串的長(zhǎng)度,和輸入?key?中最長(zhǎng)的字串長(zhǎng)度都相等。
redis BITOP指令 範(fàn)例
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