Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions redisearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class Client(object):
DICT_DUMP_CMD = 'FT.DICTDUMP'
GET_CMD = 'FT.GET'
MGET_CMD = 'FT.MGET'
CONFIG_CMD = 'FT.CONFIG'


NOOFFSETS = 'NOOFFSETS'
Expand Down Expand Up @@ -507,3 +508,30 @@ def dict_dump(self, name):
cmd = [self.DICT_DUMP_CMD, name]
raw = self.redis.execute_command(*cmd)
return raw

def set_config(self, option, value):
"""Set runtime configuration option.

### Parameters

- **option**: the name of the configuration option.
- **value**: a value for the configuration option.
"""
cmd = [self.CONFIG_CMD, 'SET', option, value]
raw = self.redis.execute_command(*cmd)
return raw == 'OK'

def get_config(self, option):
"""Get runtime configuration option value.

### Parameters

- **option**: the name of the configuration option.
"""
cmd = [self.CONFIG_CMD, 'GET', option]
res = {}
raw = self.redis.execute_command(*cmd)
if raw:
for kvs in raw:
res[kvs[0]] = kvs[1]
return res
8 changes: 8 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,14 @@ def testGet(self):
self.assertEqual([['f1', 'some valid content dd2', 'f2', 'this is sample text ff2']], client.get('doc2'))
self.assertEqual([['f1', 'some valid content dd1', 'f2', 'this is sample text ff1'], ['f1', 'some valid content dd2', 'f2', 'this is sample text ff2']], client.get('doc1', 'doc2'))

def testConfig(self):
client = self.getCleanClient('idx')
self.assertTrue(client.set_config('TIMEOUT', '100'))
self.assertFalse(client.set_config('TIMEOUT', "null"))
res = client.get_config('*')
self.assertEqual('100', res['TIMEOUT'])
res = client.get_config('TIMEOUT')
self.assertEqual('100', res['TIMEOUT'])

if __name__ == '__main__':

Expand Down