File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -2922,16 +2922,22 @@ def script_debug(self, *args):
2922
2922
"SCRIPT DEBUG is intentionally not implemented in the client."
2923
2923
)
2924
2924
2925
- def script_flush (self , sync_type = "SYNC" ):
2925
+ def script_flush (self , sync_type = None ):
2926
2926
"""Flush all scripts from the script cache.
2927
2927
``sync_type`` is by default SYNC (synchronous) but it can also be
2928
2928
ASYNC.
2929
2929
See: https://redis.io/commands/script-flush
2930
2930
"""
2931
- if sync_type not in ["SYNC" , "ASYNC" ]:
2932
- raise DataError ("SCRIPT FLUSH defaults to SYNC or "
2933
- "accepts SYNC/ASYNC" )
2934
- pieces = [sync_type ]
2931
+
2932
+ # Redis pre 6 had no sync_type.
2933
+ if sync_type not in ["SYNC" , "ASYNC" , None ]:
2934
+ raise DataError ("SCRIPT FLUSH defaults to SYNC in redis > 6.2, or "
2935
+ "accepts SYNC/ASYNC. For older versions, "
2936
+ "of redis leave as None." )
2937
+ if sync_type is None :
2938
+ pieces = []
2939
+ else :
2940
+ pieces = [sync_type ]
2935
2941
return self .execute_command ('SCRIPT FLUSH' , * pieces )
2936
2942
2937
2943
def script_kill (self ):
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ def test_script_flush(self, r):
43
43
r .script_load (multiply_script )
44
44
r .script_flush ()
45
45
46
+ r .set ('a' , 2 )
47
+ r .script_load (multiply_script )
48
+ r .script_flush (None )
49
+
46
50
with pytest .raises (exceptions .DataError ):
47
51
r .set ('a' , 2 )
48
52
r .script_load (multiply_script )
You can’t perform that action at this time.
0 commit comments