File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
key-value/key-value-aio/src/key_value/aio/stores/dynamodb Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff 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."""
You can’t perform that action at this time.
0 commit comments