Skip to content

Commit 65da711

Browse files
authored
Merge branch 'main' into claude/issue-172-20251029-0224
2 parents 36ca051 + 8229db5 commit 65da711

File tree

1 file changed

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

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,22 @@ async def _setup(self) -> None:
164164
waiter = self._connected_client.get_waiter("table_exists") # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
165165
await waiter.wait(TableName=self._table_name) # pyright: ignore[reportUnknownMemberType]
166166

167+
# Enable TTL on the table if not already enabled
168+
ttl_response = await self._connected_client.describe_time_to_live( # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
169+
TableName=self._table_name
170+
)
171+
ttl_status = ttl_response.get("TimeToLiveDescription", {}).get("TimeToLiveStatus") # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
172+
173+
# Only enable TTL if it's currently disabled
174+
if ttl_status == "DISABLED":
175+
await self._connected_client.update_time_to_live( # pyright: ignore[reportUnknownMemberType]
176+
TableName=self._table_name,
177+
TimeToLiveSpecification={
178+
"Enabled": True,
179+
"AttributeName": "ttl",
180+
},
181+
)
182+
167183
@override
168184
async def _get_managed_entry(self, *, key: str, collection: str) -> ManagedEntry | None:
169185
"""Retrieve a managed entry from DynamoDB."""

0 commit comments

Comments
 (0)