# BRPOP

> Remove and return the last element of the first non-empty list, waiting until one is available.

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

```
BRPOP key [key ...] timeout
```

- Group: List
- Complexity: O(N) where N is the number of keys given
- HotKV Cloud: all plans
- On-Premise: no license needed

`BRPOP` is the blocking form of [RPOP](https://docs.hotkv.com/commands/rpop/index.md). It works exactly like
[BLPOP](https://docs.hotkv.com/commands/blpop/index.md), but pops from the tail of the list instead of the
head. Keys are checked in the order given; if every list is empty or missing,
the connection waits until one of them receives an element or `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,
`BRPOP` never waits and replies at once as if the timeout had expired.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Element popped | Two-element array: the key, then the element | Same |
| 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 list holds a value
  that is not a list.

## Examples

```
127.0.0.1:6379> RPUSH jobs j1 j2
(integer) 2
127.0.0.1:6379> BRPOP jobs 0
1) "jobs"
2) "j2"
127.0.0.1:6379> BRPOP nothing 0.1
(nil)
(0.10s)
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[BLPOP](https://docs.hotkv.com/commands/blpop/index.md), [RPOP](https://docs.hotkv.com/commands/rpop/index.md), [BLMPOP](https://docs.hotkv.com/commands/blmpop/index.md),
[BLMOVE](https://docs.hotkv.com/commands/blmove/index.md), [LPUSH](https://docs.hotkv.com/commands/lpush/index.md)