1

We are using redis python client to start a local redis server for unit testing. Sample code here:

r = StrictRedis(host="localhost", port=6379)
try:
    r.ping()
except ConnectionError:
    subprocess.Popen("./redis-server")

We want to change a redis config to allow us to run unit tests correctly. Since these unit tests run on AWS Lambda, we don't have direct access to the redis-cli to make any permanent config change.

Is there any way to change redis configuration in the python code?

Note: We are not using any redis.conf for unit test. But if there is a solution using that, we can try that too.

Abhishek Garg
  • 2,158
  • 1
  • 16
  • 30

1 Answers1

3

You can change redis configuration in python code by using the config_set command

from redis import Redis
r = Redis()
r.config_set("parameter", "value")
d-h
  • 46
  • 3