tencent cloud

Tencent Cloud Distributed Cache (Redis OSS-Compatible)

bitmap Family

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-08-11 11:11:59
AI 번역

Introduction

The Bitmap command family is used to perform bit-level operations on string values by treating strings as binary bit arrays. It is suitable for scenarios that require compact encoding and efficient bitwise operations, such as user check-ins, online status bitmaps, and the underlying storage for Bloom filters. Based on their features, its core commands can be categorized into the following three types:
Single-Bit Read/Write and Counting
SETBIT / GETBIT: Set or read a single bit at a specified offset, where setting means assigning a value of 0 or 1.
BITCOUNT: Counts the number of bits with a value of 1 within a specified byte range.
BITPOS: Finds the position of the first 0 or 1 within a specified byte range.
Multi-Bitmap Bitwise Operations
BITOP: Performs bitwise operations—AND, OR, XOR, and NOT—on multiple Bitmap keys and stores the result in a destination key. It is suitable for intersection and union calculations in multi-dimensional user profiling.
Multi-Bit Integer Encoding Operations
BITFIELD / BITFIELD_RO: Reads from, writes to, and atomically increments a bit array from an integer perspective of arbitrary bit width. It supports u<N> (unsigned) and i<N> (signed) encoding and is suitable for multi-counter scenarios that require compact encoding.
For more information, see the Valkey official documentation: Bitmap Command Group.

Command Support Overview

Basic Bit Operation Commands (5): bitcount, bitop, bitpos, getbit, setbit. These commands are supported by the standard architecture of Redis versions 2.8, 4.0, 5.0, 6.2, and 7.0, as well as the standard and cluster architectures of Valkey versions 8.0 and 9.0.
Bitfield Operation Commands (2):
bitfield: is supported by Redis version 4.0 and above, and Valkey versions 8.0 and 9.0. It is not supported by the Redis 2.8 standard architecture.
bitfield_ro: is supported only by Redis versions 6.2 and 7.0, and Valkey versions 8.0 and 9.0. It is the read-only version of bitfield.
Cross-Slot Restriction: The bitop command operates on multiple source keys and writes to a destination key, and does not support cross-slot operations. All other commands operate on a single key and have no cross-slot restriction.

Command Compatibility Matrix

The support status of this command family across different versions and architectures is shown in the table below (✓ indicates supported, ✗ indicates not supported, and — indicates that the command does not involve a cross-slot access scenario).
Note:
bitpos has been enhanced with the BYTE and BIT parameters in Redis 7.0 and Valkey 8.0 and 9.0.
Command
Valkey 9.0 Standard Architecture
Valkey 9.0 Cluster Architecture
Redis 7.0 / Valkey 8.0 Standard Architecture
Redis 7.0 / Valkey 8.0 Cluster Architecture
Redis 6.2 Standard Architecture
Redis 6.2 Cluster Architecture
Redis 5.0 Standard Architecture
Redis 5.0 Cluster Architecture
Redis 4.0 Standard Architecture
Redis 4.0 Cluster Architecture
Redis 2.8 Standard Architecture
Cluster Architecture Support for Cross-Slot
bitcount
bitop
bitpos
getbit
setbit
bitfield
bitfield_ro

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백