Skip to content

Commit adec138

Browse files
committed
ref(namespacing): add namespacing support to pubsub, redis, strict,
pipeline as decorators
1 parent fac5cf5 commit adec138

File tree

7 files changed

+440
-1730
lines changed

7 files changed

+440
-1730
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ dump.rdb
77
_build
88
vagrant/.vagrant
99
.python-version
10+
.cache/

README.rst

+27-1
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,33 @@ Namespacing
672672
>>> r.get('foo')
673673
'bar'
674674
675+
Important: Any application code that accesses data structures that store
676+
key names will not return keys with the namespace stripped. For example:
677+
678+
.. code-block:: pycon
679+
680+
r = redis.StrictRedis(namespace="ns:", ...)
681+
for key in r.blpop():
682+
data = r.get(key)
683+
# do something with data
684+
# if data is a key it will not have the namespace removed
685+
686+
### OR
687+
688+
for key in r.keys('myapp:*'):
689+
data = r.get(key)
690+
691+
692+
To strip the namespace from the keys manually you can use the `remove_namespace`
693+
function.
694+
695+
.. code-block:: pycon
696+
697+
r = redis.StrictRedis(namespace="ns:", ...)
698+
for key in r.keys('myapp:*'):
699+
data = r.remove_namespace(r.get(key))
700+
701+
675702
Author
676703
^^^^^^
677704

@@ -684,4 +711,3 @@ Special thanks to:
684711
which some of the socket code is still used.
685712
* Alexander Solovyov for ideas on the generic response callback system.
686713
* Paul Hubbard for initial packaging support.
687-

0 commit comments

Comments
 (0)