@@ -226,7 +226,7 @@ async def create(self, key: str, value: bytes, validate_keys: bool = True, msg_t
226226
227227 pa = None
228228 try :
229- pa = await self .update (key , value , last = 0 , validate_keys = validate_keys , msg_ttl = msg_ttl )
229+ pa = await self ._update (key , value , last = 0 , validate_keys = validate_keys , msg_ttl = msg_ttl )
230230 except nats .js .errors .KeyWrongLastSequenceError as err :
231231 # In case of attempting to recreate an already deleted key,
232232 # the client would get a KeyWrongLastSequenceError. When this happens,
@@ -246,7 +246,7 @@ async def create(self, key: str, value: bytes, validate_keys: bool = True, msg_t
246246 # to recreate using the last revision.
247247 raise err
248248 except nats .js .errors .KeyDeletedError as err :
249- pa = await self .update (
249+ pa = await self ._update (
250250 key , value , last = err .entry .revision , validate_keys = validate_keys , msg_ttl = msg_ttl
251251 )
252252
@@ -258,14 +258,20 @@ async def update(
258258 value : bytes ,
259259 last : Optional [int ] = None ,
260260 validate_keys : bool = True ,
261- msg_ttl : Optional [float ] = None ,
262261 ) -> int :
263262 """
264263 update will update the value if the latest revision matches.
265-
266- Note: TTL parameter is accepted for internal use by create(), but should not be
267- used directly on update operations per NATS KV semantics.
268264 """
265+ return await self ._update (key , value , last = last , validate_keys = validate_keys )
266+
267+ async def _update (
268+ self ,
269+ key : str ,
270+ value : bytes ,
271+ last : Optional [int ] = None ,
272+ validate_keys : bool = True ,
273+ msg_ttl : Optional [float ] = None ,
274+ ) -> int :
269275 if validate_keys and not _is_key_valid (key ):
270276 raise nats .js .errors .InvalidKeyError (key )
271277
@@ -286,15 +292,17 @@ async def update(
286292 return pa .seq
287293
288294 async def delete (
289- self , key : str , last : Optional [int ] = None , validate_keys : bool = True , msg_ttl : Optional [float ] = None
295+ self ,
296+ key : str ,
297+ last : Optional [int ] = None ,
298+ validate_keys : bool = True ,
290299 ) -> bool :
291300 """
292301 delete will place a delete marker and remove all previous revisions.
293302
294303 :param key: The key to delete
295304 :param last: Expected last revision number (for optimistic concurrency)
296305 :param validate_keys: Whether to validate the key format
297- :param msg_ttl: Optional TTL (time-to-live) in seconds for the delete marker
298306 """
299307 if validate_keys and not _is_key_valid (key ):
300308 raise nats .js .errors .InvalidKeyError (key )
@@ -305,7 +313,7 @@ async def delete(
305313 if last and last > 0 :
306314 hdrs [api .Header .EXPECTED_LAST_SUBJECT_SEQUENCE ] = str (last )
307315
308- await self ._js .publish (f"{ self ._pre } { key } " , headers = hdrs , msg_ttl = msg_ttl )
316+ await self ._js .publish (f"{ self ._pre } { key } " , headers = hdrs )
309317 return True
310318
311319 async def purge (self , key : str , msg_ttl : Optional [float ] = None ) -> bool :
0 commit comments