I want to write some values into different database, this is my code:
import redis
r1 = redis.Redis(host='127.0.0.1', port=6379, db = 'db1')
r2 = redis.Redis(host='127.0.0.1', port=6379, db = 'db2')
numList = ['4', '3', '2', '1']
for num in numList:
r1.lpush('a', num)
r2.lpush('a', 'test')
print r1.lrange('a',start=0,end=-1)
print r2.lrange('a',start=0,end=-1)
Then I got this result:
['test', '1', 'test', '2', 'test', '3', 'test', '4']
['test', '1', 'test', '2', 'test', '3', 'test', '4']
Although I use different database, but for the same key, all the value is put in. Thank you.
Redis comes with support for multiple databases, which is very similar to the concept in SQL databases. In SQL databases, such as MySQL, PostgreSQL, and Oracle, you can define a name for your databases. However, Redis databases are represented by numbers.
Large number of connectionsRedis is a single-threaded process based on an event loop where incoming client requests are handled sequentially. That means the response time of a given client becomes longer as the number of connected clients increases.
DBs are supposed to be zero-based numeric index (apperently the limit is 15). Try using
r1 = redis.Redis(host='127.0.0.1', port=6379, db = 0)
r2 = redis.Redis(host='127.0.0.1', port=6379, db = 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With