You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mostly used with two source bitmaps, a bit in `destkey` is set only if its value differs between the two source bitmaps.
95
117
*`BITOP NOT destkey srckey`
96
118
97
-
As you can see **NOT** is special as it only takes an input key, because it
98
-
performs inversion of bits so it only makes sense as a unary operator.
119
+
`NOT` is a unary operator and only supports a single source bitmap; set the bit to the inverse of its value in the source bitmap.
120
+
*`BITOP DIFF destkey X [Y1 Y2 ...]` <sup>[1](#list-note-1)</sup>
121
+
122
+
A bit in `destkey` is set if it is set in `X`, but not in any of `Y1, Y2, ...` .
123
+
*`BITOP DIFF1 destkey X [Y1 Y2 ...]` <sup>[1](#list-note-1)</sup>
99
124
100
-
The result of the operation is always stored at `destkey`.
125
+
A bit in `destkey` is set if it is set in one or more of `Y1, Y2, ...`, but not in `X`.
126
+
*`BITOP ANDOR destkey X [Y1 Y2 ...]` <sup>[1](#list-note-1)</sup>
127
+
128
+
A bit in `destkey` is set if it is set in `X` and also in one or more of `Y1, Y2, ...`.
129
+
*`BITOP ONE destkey X1 [X2 X3 ...]` <sup>[1](#list-note-1)</sup>
130
+
131
+
A bit in `destkey` is set if it is set in exactly one of `X1, X2, ...`.
132
+
133
+
The result of each operation is always stored at `destkey`.
134
+
135
+
1. <aname="list-note-1"></a> Added in Redis 8.2.
101
136
102
137
## Handling of strings with different lengths
103
138
@@ -110,13 +145,27 @@ zero bytes up to the length of the longest string.
110
145
111
146
## Examples
112
147
148
+
1. Basic usage example using the `AND` operator:
149
+
113
150
{{% redis-cli %}}
114
-
SET key1 "foobar"
115
-
SET key2 "abcdef"
151
+
BITFIELD key1 SET i8 #0 255
152
+
BITFIELD key2 SET i8 #0 85
116
153
BITOP AND dest key1 key2
117
-
GET dest
154
+
BITFIELD dest GET i8 #0
118
155
{{% /redis-cli %}}
119
156
157
+
2. Suppose you want to expose people to a book-related ad. The target audience is people who love to read books and are interested in fantasy, adventure, or science fiction. Assume you have the following bitmaps:
158
+
159
+
*`LRB` - people who love to read books.
160
+
*`B:F` - people interested in fantasy.
161
+
*`B:A` - people interested in adventure.
162
+
*`B:SF` - people interested in science fiction.
163
+
164
+
To create a bitmap representing the target audience, use the following command:
Use this command to get an array of slot usage statistics for the slots assigned to the current shard. If you're working with a Redis cluster, this data helps you understand overall slot usage, spot hot or cold slots, plan slot migrations to balance load, or refine your application logic to better distribute keys.
95
+
96
+
## Options
97
+
98
+
`CLUSTER SLOT-STATS` has two mutually exclusive options:
99
+
100
+
*`ORDERBY`: Sorts the slot statistics by the specified metric. Use ASC or DESC to sort in ascending or descending order. If multiple slots have the same value, the command uses the slot number as a tiebreaker, sorted in ascending order.
101
+
102
+
*`SLOTSRANGE`: Limits the results to a specific, inclusive range of slots. Results are always sorted by slot number in ascending order.
103
+
104
+
The command reports on the following statistics:
105
+
106
+
*`KEY-COUNT`: Number of keys stored in the slot.
107
+
*`CPU-USEC`: CPU time (in microseconds) spent handling the slot.
108
+
*`NETWORK-BYTES-IN`: Total inbound network traffic (in bytes) received by the slot.
109
+
*`NETWORK-BYTES-OUT`: Total outbound network traffic (in bytes) sent from the slot.
110
+
111
+
## Return information
112
+
113
+
{{< multitabs id=“cmd-name-return-info"
114
+
tab1="RESP2"
115
+
tab2="RESP3" >}}
116
+
117
+
One of the following:
118
+
119
+
*[Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}): a nested list of slot usage statistics.
[Integer reply](../../develop/reference/protocol-spec#integers): `0` if the element does not exist in the vector set, or the key does not exist. `1` if the element exists in the vector set.
61
+
62
+
-tab-sep-
63
+
64
+
[Boolean reply](../../develop/reference/protocol-spec#booleans): `false` if the element does not exist in the vector set, or the key does not exist. `true` if the element exists in the vector set.
0 commit comments