diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2018-11-14 13:36:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 13:36:56 -0800 |
commit | e9f5826a474b9371b3b6c25a297b7e4ef40f8eb1 (patch) | |
tree | aed0828021bbcbb5ac8bbd2837c54a4ed8c87a8b /redis | |
parent | 69effc2464fada8a51658f97d8a251b2e736e34d (diff) | |
parent | 477bb180b47666c5175f4a609d203eb276246d86 (diff) | |
download | redis-py-e9f5826a474b9371b3b6c25a297b7e4ef40f8eb1.tar.gz |
Merge pull request #1042 from dwilliams-kenzan/master
Adding a NOSAVE option to the SHUTDOWN command
Diffstat (limited to 'redis')
-rwxr-xr-x | redis/client.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/redis/client.py b/redis/client.py index 94853b6..c34f781 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1022,10 +1022,22 @@ class StrictRedis(object): "Returns a list of slaves for ``service_name``" return self.execute_command('SENTINEL SLAVES', service_name) - def shutdown(self): - "Shutdown the server" + def shutdown(self, save=False, nosave=False): + """Shutdown the Redis server. If Redis has persistence configured, + data will be flushed before shutdown. If the "save" option is set, + a data flush will be attempted even if there is no persistence + configured. If the "nosave" option is set, no data flush will be + attempted. The "save" and "nosave" options cannot both be set. + """ + if save and nosave: + raise RedisError('SHUTDOWN save and nosave cannot both be set') + args = ['SHUTDOWN'] + if save: + args.append('SAVE') + if nosave: + args.append('NOSAVE') try: - self.execute_command('SHUTDOWN') + self.execute_command(*args) except ConnectionError: # a ConnectionError here is expected return |