Redis Getbit コマンド

Redis 文字列(string)

Redis Getbit コマンドは、key に保存されている文字列値の指定されたオフセット上のビット(bit)を取得します。

構文

redis Getbit コマンドの基本的な構文は次のとおりです:

redis 127.0.0.1:6379> GETBIT KEY_NAME OFFSET

利用可能なバージョン

>= 2.2.0

戻り値

文字列値の指定されたオフセット上のビット(bit)。

オフセット OFFSET が文字列値の長さより大きい場合、または key が存在しない場合は 0 を返します。

例

# 对不存在的 key 或者不存在的 offset 进行 GETBIT, 返回 0

redis> EXISTS bit
(integer) 0

redis> GETBIT bit 10086
(integer) 0


# 对已存在的 offset 进行 GETBIT

redis> SETBIT bit 10086 1
(integer) 0

redis> GETBIT bit 10086
(integer) 1

Redis 文字列(string)

その他の拡張