How to select the correct redis db instance when using redis-om?

53 views Asked by At

This example on Redis Developer on Github shows how the model is hard-wired with a redis instance.

When one wants to use a library of models, that is not an option, because the library author would not know to what redis instance the user of the models wants to connect.

By default the save() method would try to save in JsonModel/HashModel in localhost:6379/db0. However, how would one change that imperatively in the code? Also with the requirement, that one could use multiple redis instances in the same py file/module.

Using the environment variable does not appear to work: os.environ["REDIS_OM_URL"]="redis://@localhost:6380" Anyhow, it would not help, because what if you have multiple DBs with for models - and a model could appear in multiple domains (which really happens quiet often).

0

There are 0 answers