Namespaces in Redis?

2019-03-22 19:12发布

Is it possible to create namespaces in Redis?

From what I found, all the global commands (count, delete all) work on all the objects. Is there a way to create sub-spaces such that these commands will be limited in context?

I don't want to set up different Redis servers for this purpose.

I assume the answer is "No", and wonder why wasn't this implemented, as it seems to be a useful feature without too much overhead.

标签: nosql redis
2条回答
叼着烟拽天下
2楼-- · 2019-03-22 19:22

A Redis server can handle multiple databases... which are numbered. I think it provides 32 of them by default; you can access them using the -n option to the redis-cli shell scripting command and by similar options to the connection arguments or using the "select()" method on its connection objects. (In this case .select() is the method name for the Python Redis module ... I presume it's named similarly for other libraries and interfaces.

There's an option to control how many separate databases you want in the configuration file for the Redis server daemon as well. I don't know what the upper limit would be and there doesn't seem to be a way to dynamically change that (in other words it seems that you'd have to shutdown and restart the server to add additional DBs). Also, there doesn't seem to be an away to associate these DB numbers with any sort of name nor to impose separate ACLS, nor even different passwords, to them. Redis, of course, is schema-less as well.

查看更多
▲ chillily
3楼-- · 2019-03-22 19:32
登录 后发表回答