redis_service.operations.list_
list_
codex_platform.redis_service.operations.list_
Redis List operations.
Classes
ListOperations
Redis List operations (RPUSH / LPUSH / LPOP / LRANGE and more).
Accepts an already-constructed redis.asyncio.Redis client.
All methods wrap Redis errors in typed exceptions.
Example::
ops = ListOperations(client)
await ops.push("queue:jobs", "job-1", "job-2")
job = await ops.pop("queue:jobs")
Source code in src/codex_platform/redis_service/operations/list_.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
Functions
push(key, *values, **kwargs)
async
Append one or more values to the end of a list (RPUSH).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
*values
|
str
|
String values to append. |
()
|
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
int
|
New length of the list after the operation. |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
lpush(key, *values, **kwargs)
async
Prepend one or more values to the beginning of a list (LPUSH).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
*values
|
str
|
String values to prepend. |
()
|
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
int
|
New length of the list after the operation. |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
pop(key, **kwargs)
async
Remove and return the first element of a list (LPOP).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
str | None
|
The first element, or |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
rpop(key, **kwargs)
async
Remove and return the last element of a list (RPOP).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
str | None
|
The last element, or |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
brpop(*keys, timeout=0)
async
Blocking pop of the last element from the first non-empty list (BRPOP).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*keys
|
str
|
One or more Redis key strings to check in order. |
()
|
timeout
|
int
|
Maximum seconds to block. |
0
|
Returns:
| Type | Description |
|---|---|
tuple[str, str] | None
|
|
tuple[str, str] | None
|
or |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
range(key, start=0, end=-1, **kwargs)
async
Return a slice of list elements by index range (LRANGE).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
start
|
int
|
Start index (0-based). Negative values count from the end. |
0
|
end
|
int
|
End index inclusive. |
-1
|
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of elements in the requested range. |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
length(key, **kwargs)
async
Return the number of elements in a list (LLEN).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
int
|
List length. |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
set_index(key, index, value, **kwargs)
async
Set the element at a specific list index (LSET).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
index
|
int
|
Zero-based index. Negative values count from the end. |
required |
value
|
str
|
New value to set at the given index. |
required |
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
trim(key, start, end, **kwargs)
async
Trim a list to the specified index range, discarding all other elements (LTRIM).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | BaseRedisKey
|
Redis key or a |
required |
start
|
int
|
Start index (inclusive). |
required |
end
|
int
|
End index (inclusive). |
required |
**kwargs
|
Any
|
Extra parameters forwarded to |
{}
|
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |
Source code in src/codex_platform/redis_service/operations/list_.py
move(src, dst)
async
Atomically move the last element of src to the head of dst (RPOPLPUSH).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
str
|
Source list key. |
required |
dst
|
str
|
Destination list key. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The moved element, or |
Raises:
| Type | Description |
|---|---|
RedisConnectionError
|
Redis connection failure. |
RedisServiceError
|
Redis operation failure. |