Skip to content

Commit 5ba24e5

Browse files
fix: use expires_at directly for DynamoDB TTL timestamp
The managed_entry.ttl property returns remaining seconds from NOW, not the original TTL duration. This caused incorrect TTL timestamps when there was any delay between entry creation and property access. Using expires_at directly ensures the timestamp is always correct. Fixes test failures in older dependency versions where timing delays were more common. Co-authored-by: William Easton <strawgate@users.noreply.github.com>
1 parent eb94c25 commit 5ba24e5

File tree

1 file changed

+2
-2
lines changed
  • key-value/key-value-aio/src/key_value/aio/stores/dynamodb

1 file changed

+2
-2
lines changed

key-value/key-value-aio/src/key_value/aio/stores/dynamodb/store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ async def _put_managed_entry(
226226
}
227227

228228
# Add TTL if present
229-
if managed_entry.ttl is not None and managed_entry.created_at is not None:
229+
if managed_entry.expires_at is not None:
230230
# DynamoDB TTL expects a Unix timestamp
231-
ttl_timestamp = int(managed_entry.created_at.timestamp() + managed_entry.ttl)
231+
ttl_timestamp = int(managed_entry.expires_at.timestamp())
232232
item["ttl"] = {"N": str(ttl_timestamp)}
233233

234234
await self._connected_client.put_item( # pyright: ignore[reportUnknownMemberType]

0 commit comments

Comments
 (0)