# BZPOPMIN

> Remove and return the lowest-scored member of the first non-empty sorted set, waiting until one is available.

URL: https://docs.hotkv.com/commands/bzpopmin/

```
BZPOPMIN key [key ...] timeout
```

- Group: Sorted set
- Complexity: O(log(N)) where N is the size of the sorted set
- HotKV Cloud: all plans
- On-Premise: no license needed

`BZPOPMIN` is the blocking form of [ZPOPMIN](https://docs.hotkv.com/commands/zpopmin/index.md). It checks
the keys in the order given and pops the lowest-scored member of the first one
that holds a non-empty sorted set. If every sorted set is empty or missing, the
connection waits until another client adds a member to one of the keys, or
until `timeout` passes.

`timeout` is in seconds and can have a fractional part. `0` waits forever.
Inside [MULTI](https://docs.hotkv.com/commands/multi/index.md) / [EXEC](https://docs.hotkv.com/commands/exec/index.md) and inside scripts,
`BZPOPMIN` never waits and replies at once as if the timeout had expired.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Member popped | Three-element array: the key, the member, the score (bulk string) | Three-element array: key, member, score (double) |
| Timeout expired | Nil array | Null |

Errors:

- `ERR timeout is not a float or out of range`, `ERR timeout is negative`, or
  `ERR timeout is out of range` for a bad `timeout`.
- `WRONGTYPE` if a key reached before the first non-empty sorted set holds a
  value that is not a sorted set.

## Examples

```
127.0.0.1:6379> ZADD tasks 2 "normal" 1 "urgent"
(integer) 2
127.0.0.1:6379> BZPOPMIN empty tasks 5
1) "tasks"
2) "urgent"
3) "1"
127.0.0.1:6379> BZPOPMIN empty 0.5
(nil)
(0.50s)
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[BZPOPMAX](https://docs.hotkv.com/commands/bzpopmax/index.md), [ZPOPMIN](https://docs.hotkv.com/commands/zpopmin/index.md), [BZMPOP](https://docs.hotkv.com/commands/bzmpop/index.md),
[BLPOP](https://docs.hotkv.com/commands/blpop/index.md)