redis / redis-py

Redis Python client
MIT License
12.67k stars 2.53k forks source link

Feature request: Namespace support #12

Open mjrusso opened 14 years ago

mjrusso commented 14 years ago

Proposal:

r = redis.Redis(namespace='foobar')

Behind-the-scenes, this would prefix every key with foobar.

For example, if I issued the following command:

r.set('abc', 'xyz')

It would be equivalent to the following:

redis-cli set foobar:abc xyz

In Ruby, the redis-namespace class does the same thing.

However, I think that it would be preferable if this were a core feature of the Python client.

trulede commented 3 years ago

A while back I implemented a small class to do this. I called it a "keyspace" and basically it took care of the prefix (i.e. namespace) and also had a hash which kept track of all the keys created in the namespace. It also had some capability to manage TTL on keys and a few other things. The api was/is more or less:

foo = keyspace("foo") foo.key = "foo" foo.mkey("bar") = "foo.bar"

It's not really complicated to implement, and whatever you do, it probably will not hit my use-case exactly. So is it really something that belongs as a part of redis-py? It could be better as a separate project.

el1s7 commented 3 years ago

Year 2047, this feature still not implemented

Sanix-Darker commented 2 years ago

+10000000000000000000000000000000000000000000000000000000000000000000

JoshSanch commented 2 years ago

+1. This feature would be very useful for enforcing data isolation in a multi-tenancy use case where different client instances may use the same database but shouldn't touch each other's keys.

ddcatgg commented 2 years ago

+1

Allineer commented 2 years ago

+1

lilcryptopump commented 2 years ago

👀

hyperleex commented 2 years ago

+1

ospikovets commented 1 year ago

+1

nikhildigde commented 1 year ago

+1 - Would help with multi tenancy solutions with shared db

dawngo commented 10 months ago

+1

Elyasnz commented 9 months ago

any good news for this one!?

Elyasnz commented 9 months ago

maybe something like this being implemented in the main package!?

https://pypi.org/project/redis-namespace/