@@ -332,12 +332,12 @@ def get_redis_connection(self, key: str, transaction: bool = True) -> Pipeline:
332
332
pipe = conn .pipeline (transaction = transaction )
333
333
return pipe
334
334
335
- def _execute_redis_operation (
335
+ def _execute_redis_operation_no_txn (
336
336
self , key : str , operation : RedisOperation , * args : Any , ** kwargs : Any
337
337
) -> Any :
338
338
metrics_str = f"redis_buffer.{ operation .value } "
339
339
metrics .incr (metrics_str )
340
- pipe = self .get_redis_connection (self .pending_key )
340
+ pipe = self .get_redis_connection (self .pending_key , transaction = False )
341
341
getattr (pipe , operation .value )(key , * args , ** kwargs )
342
342
if args :
343
343
pipe .expire (key , self .key_expire )
@@ -356,7 +356,7 @@ def _execute_sharded_redis_operation(
356
356
357
357
metrics_str = f"redis_buffer.{ operation .value } "
358
358
metrics .incr (metrics_str , amount = len (keys ))
359
- pipe = self .get_redis_connection (self .pending_key )
359
+ pipe = self .get_redis_connection (self .pending_key , transaction = False )
360
360
for key in keys :
361
361
getattr (pipe , operation .value )(key , * args , ** kwargs )
362
362
if args :
@@ -369,10 +369,10 @@ def push_to_sorted_set(self, key: str, value: list[int] | int) -> None:
369
369
value_dict = {v : now for v in value }
370
370
else :
371
371
value_dict = {value : now }
372
- self ._execute_redis_operation (key , RedisOperation .SORTED_SET_ADD , value_dict )
372
+ self ._execute_redis_operation_no_txn (key , RedisOperation .SORTED_SET_ADD , value_dict )
373
373
374
374
def get_sorted_set (self , key : str , min : float , max : float ) -> list [tuple [int , float ]]:
375
- redis_set = self ._execute_redis_operation (
375
+ redis_set = self ._execute_redis_operation_no_txn (
376
376
key ,
377
377
RedisOperation .SORTED_SET_GET_RANGE ,
378
378
min = min ,
@@ -410,7 +410,9 @@ def bulk_get_sorted_set(
410
410
return data_to_timestamps
411
411
412
412
def delete_key (self , key : str , min : float , max : float ) -> None :
413
- self ._execute_redis_operation (key , RedisOperation .SORTED_SET_DELETE_RANGE , min = min , max = max )
413
+ self ._execute_redis_operation_no_txn (
414
+ key , RedisOperation .SORTED_SET_DELETE_RANGE , min = min , max = max
415
+ )
414
416
415
417
def delete_keys (self , keys : list [str ], min : float , max : float ) -> None :
416
418
self ._execute_sharded_redis_operation (
@@ -427,7 +429,7 @@ def delete_hash(
427
429
fields : list [str ],
428
430
) -> None :
429
431
key = self ._make_key (model , filters )
430
- pipe = self .get_redis_connection (self .pending_key )
432
+ pipe = self .get_redis_connection (self .pending_key , transaction = False )
431
433
for field in fields :
432
434
getattr (pipe , RedisOperation .HASH_DELETE .value )(key , field )
433
435
pipe .expire (key , self .key_expire )
@@ -441,7 +443,7 @@ def push_to_hash(
441
443
value : str ,
442
444
) -> None :
443
445
key = self ._make_key (model , filters )
444
- self ._execute_redis_operation (key , RedisOperation .HASH_ADD , field , value )
446
+ self ._execute_redis_operation_no_txn (key , RedisOperation .HASH_ADD , field , value )
445
447
446
448
def push_to_hash_bulk (
447
449
self ,
@@ -450,11 +452,11 @@ def push_to_hash_bulk(
450
452
data : dict [str , str ],
451
453
) -> None :
452
454
key = self ._make_key (model , filters )
453
- self ._execute_redis_operation (key , RedisOperation .HASH_ADD_BULK , data )
455
+ self ._execute_redis_operation_no_txn (key , RedisOperation .HASH_ADD_BULK , data )
454
456
455
457
def get_hash (self , model : type [models .Model ], field : dict [str , BufferField ]) -> dict [str , str ]:
456
458
key = self ._make_key (model , field )
457
- redis_hash = self ._execute_redis_operation (key , RedisOperation .HASH_GET_ALL )
459
+ redis_hash = self ._execute_redis_operation_no_txn (key , RedisOperation .HASH_GET_ALL )
458
460
decoded_hash = {}
459
461
for k , v in redis_hash .items ():
460
462
if isinstance (k , bytes ):
@@ -467,7 +469,7 @@ def get_hash(self, model: type[models.Model], field: dict[str, BufferField]) ->
467
469
468
470
def get_hash_length (self , model : type [models .Model ], field : dict [str , BufferField ]) -> int :
469
471
key = self ._make_key (model , field )
470
- return self ._execute_redis_operation (key , RedisOperation .HASH_LENGTH )
472
+ return self ._execute_redis_operation_no_txn (key , RedisOperation .HASH_LENGTH )
471
473
472
474
def incr (
473
475
self ,
0 commit comments