I want to write application in python which uses redis. I googled but I could not find any results for my question. Usually, I do this:
import redis
rs = redis.Redis('localhost')
then do all gets and sets. But can I in redis do something like this:
rs1 = redis.Redis('app1')
rs2 = redis.Redis('app2')
I mean, I want to use two or more instances, each of which stores different things (for example rs1 for urls, rs2 for headers, etc...). And also I want to know how to delete all keys (for example in rs1 delete all records). Any good tutorial, resource? Note: I need to use redis because I need to preform fast check and store, like url-seen for crawler.
As showed in the getting started section of the docs
redis.Redis
andredis.StrictRedis
both take an integerdb
argument as a constructor parameter. That will get you an effectively silo'ed instance.You could do something like the following:
flushdb()
will clear all the keys for the database you are connected to, whileflushall()
will clear all the keys for every database.