diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-10-25 13:41:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-25 13:41:06 +0300 |
commit | 0ef4c0711693b4b313ce97261214bd151d8261d5 (patch) | |
tree | 58887c0873fca123f47066608bcc02ff761e8273 /redis | |
parent | 36e00ec4e22a9f947e099affdfdc79862ac7ca08 (diff) | |
download | redis-py-0ef4c0711693b4b313ce97261214bd151d8261d5.tar.gz |
Pre 6.2 redis should default to None for script flush (#1641)
Diffstat (limited to 'redis')
-rw-r--r-- | redis/commands.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/redis/commands.py b/redis/commands.py index f5243e4..2697e78 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -2922,16 +2922,22 @@ class Commands: "SCRIPT DEBUG is intentionally not implemented in the client." ) - def script_flush(self, sync_type="SYNC"): + def script_flush(self, sync_type=None): """Flush all scripts from the script cache. ``sync_type`` is by default SYNC (synchronous) but it can also be ASYNC. See: https://redis.io/commands/script-flush """ - if sync_type not in ["SYNC", "ASYNC"]: - raise DataError("SCRIPT FLUSH defaults to SYNC or " - "accepts SYNC/ASYNC") - pieces = [sync_type] + + # Redis pre 6 had no sync_type. + if sync_type not in ["SYNC", "ASYNC", None]: + raise DataError("SCRIPT FLUSH defaults to SYNC in redis > 6.2, or " + "accepts SYNC/ASYNC. For older versions, " + "of redis leave as None.") + if sync_type is None: + pieces = [] + else: + pieces = [sync_type] return self.execute_command('SCRIPT FLUSH', *pieces) def script_kill(self): |