@@ -595,16 +595,10 @@ async def aput(
595595
596596 # Apply TTL if configured
597597 if self .ttl_config and "default_ttl" in self .ttl_config :
598- all_keys = (
599- [checkpoint_key ] + [key for key , _ in blobs ]
600- if blobs
601- else [checkpoint_key ]
598+ await self ._apply_ttl_to_keys (
599+ checkpoint_key ,
600+ [key for key , _ in blobs ] if blobs else None ,
602601 )
603- ttl_minutes = self .ttl_config .get ("default_ttl" )
604- ttl_seconds = int (ttl_minutes * 60 )
605-
606- for key in all_keys :
607- await self ._redis .expire (key , ttl_seconds )
608602 else :
609603 # For non-cluster mode, use pipeline with transaction for atomicity
610604 pipeline = self ._redis .pipeline (transaction = True )
@@ -622,19 +616,10 @@ async def aput(
622616
623617 # Apply TTL to checkpoint and blob keys if configured
624618 if self .ttl_config and "default_ttl" in self .ttl_config :
625- all_keys = (
626- [checkpoint_key ] + [key for key , _ in blobs ]
627- if blobs
628- else [checkpoint_key ]
619+ await self ._apply_ttl_to_keys (
620+ checkpoint_key ,
621+ [key for key , _ in blobs ] if blobs else None ,
629622 )
630- ttl_minutes = self .ttl_config .get ("default_ttl" )
631- ttl_seconds = int (ttl_minutes * 60 )
632-
633- # Use a new pipeline for TTL operations
634- ttl_pipeline = self ._redis .pipeline ()
635- for key in all_keys :
636- ttl_pipeline .expire (key , ttl_seconds )
637- await ttl_pipeline .execute ()
638623
639624 return next_config
640625
@@ -780,11 +765,10 @@ async def aput_writes(
780765 and self .ttl_config
781766 and "default_ttl" in self .ttl_config
782767 ):
783- ttl_minutes = self .ttl_config .get ("default_ttl" )
784- ttl_seconds = int (ttl_minutes * 60 )
785-
786- for key in created_keys :
787- await self ._redis .expire (key , ttl_seconds )
768+ await self ._apply_ttl_to_keys (
769+ created_keys [0 ],
770+ created_keys [1 :] if len (created_keys ) > 1 else None ,
771+ )
788772 else :
789773 # For non-cluster mode, use transaction pipeline for atomicity
790774 pipeline = self ._redis .pipeline (transaction = True )
0 commit comments