SubRedis is a simple namespace wrapper for Redis, generating completely sandboxed redises to enhance application safety and modularity.
Subredis allows creating redis's within an existing redis (or subredis) by prepending a prefix to the key before interacting with redis. Each subredis exists in a redis-compatible but isolated bubble unaffected by other subredis activity going on in the application. See [sample usage](##Sample Usage) for examples.
You can read more in this blog post.
pip install subredis
from subredis import SubRedis
redis = redis.from_url('redis://localhost:6379')
subred = SubRedis("keyspace", redis)
subred.set("foo", "bar") # stores keyspace_foo -> bar
subred.get("foo") # gets keyspace_foo
subred.flushdb() # flushes everything in "keyspace"
# Redis storing info about this student's classes
subred = SubRedis(studentId + "-classes", redis)
subred.set("name", "Biology")
subred.set("teacher", "Professor Tim")
# Redis storing info about this student's grades in this class
subred2 = SubRedis(classId + "-grades", subred)
subred2.set("Midterm", "89")
subred2.set("Final Project", "72")
Subredis intends to support nearly all features of a StrictRedis instance with the following exceptions:
- Lua Scripting
- Many Redis "Admin" interface calls (ie bgsave, etc)
Released under Apache license. See here for more info.
(C) Doug Turnbull, 2013