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):
29222922 "SCRIPT DEBUG is intentionally not implemented in the client."
29232923 )
29242924
2925- def script_flush (self , sync_type = "SYNC" ):
2925+ def script_flush (self , sync_type = None ):
29262926 """Flush all scripts from the script cache.
29272927 ``sync_type`` is by default SYNC (synchronous) but it can also be
29282928 ASYNC.
29292929 See: https://redis.io/commands/script-flush
29302930 """
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 ]
29352941 return self .execute_command ('SCRIPT FLUSH' , * pieces )
29362942
29372943 def script_kill (self ):
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ def test_script_flush(self, r):
4343 r .script_load (multiply_script )
4444 r .script_flush ()
4545
46+ r .set ('a' , 2 )
47+ r .script_load (multiply_script )
48+ r .script_flush (None )
49+
4650 with pytest .raises (exceptions .DataError ):
4751 r .set ('a' , 2 )
4852 r .script_load (multiply_script )
You can’t perform that action at this time.
0 commit comments