fix(proxy): build Redis spend-log rows as tuples and pin the LTRIM window in the pipeline test

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yassin 2026-09-20 09:16:50 +00:00
parent 9e53ee5f04
commit 65bf78b567
2 changed files with 3 additions and 3 deletions

View file

@ -554,7 +554,7 @@ class RedisUpdateBuffer:
try:
buffer_size: Final = await self.redis_cache.async_rpush_and_trim(
key=REDIS_SPEND_LOGS_BUFFER_KEY,
values=[_encode_spend_log_row(row) for row in rows],
values=tuple(_encode_spend_log_row(row) for row in rows),
max_len=max_rows,
)
overflow: Final = buffer_size - max_rows
@ -582,7 +582,7 @@ class RedisUpdateBuffer:
)
if popped is None:
return ()
encoded_rows: Final = popped if isinstance(popped, list) else [popped]
encoded_rows: Final = tuple(popped) if isinstance(popped, list) else (popped,)
decoded_rows: Final = (_decode_spend_log_row(encoded) for encoded in encoded_rows)
return tuple(row for row in decoded_rows if row is not None)

View file

@ -1549,4 +1549,4 @@ async def test_async_rpush_and_trim_runs_push_and_trim_in_one_transaction(monkey
client.pipeline.assert_called_once_with(transaction=True)
assert pushed_len == 4
assert rows == ["b", "c", "d"]
assert [op[:2] for op in pipe.queued] == [("rpush", "ns:buf"), ("ltrim", "ns:buf")]
assert pipe.queued == [("rpush", "ns:buf", "c", "d"), ("ltrim", "ns:buf", "-3", "-1")]