由于我对 redis 还很陌生,因此我正在尝试探索各种选项,看看如何使用 redis 实现 Multi-Tenancy 。
我在 redisLabs 官方页面上阅读了一些文档,看起来 redis 集群模式支持 redis 企业开箱即用的 Multi-Tenancy 。
我想知道在哨兵模式下是否也可以使用这种 Multi-Tenancy 解决方案?
我可能对 redis 企业提供的 Multi-Tenancy 完全混淆。可能它也可以在哨兵模式下工作,但对我来说似乎没有什么很清楚。
有人可以对 redis 中的 Multi-Tenancy 有所了解吗?什么模式支持它?
最佳答案
如果您打算使用 redis-cluster
,那么只支持一个 DB。
Redis Cluster does not support multiple databases like the stand alone version of Redis. There is just database 0 and the SELECT command is not allowed.
如果你不打算使用集群模式,那么你可以看看Redis的创建者发布的关于多个数据库的消息(几年前)
I understand how this can be useful, but unfortunately I consider Redis multiple database errors my worst decision in Redis design at all... without any kind of real gain, it makes the internals a lot more complex. The reality is that databases don't scale well for a number of reason, like active expire of keys and VM. If the DB selection can be performed with a string I can see this feature being used as a scalable O(1) dictionary layer, that instead it is not.
With DB numbers, with a default of a few DBs, we are communication better what this feature is and how can be used I think. I hope that at some point we can drop the multiple DBs support at all, but I think it is probably too late as there is a number of people relying on this feature for their work.
Salvatore's message
Redis cluster documentation
我可能建议的是前缀。我们在 SaaS 应用程序中使用此方法,所有不同的数据类型都以相关客户名称为前缀。我们处理应用层的一些操作。
如果你想使用单实例/多数据库,那么你需要通过使用
select
在你的代码库上管理它们。命令。可能有一些库来管理它们。关键的事情之一是;All databases are still persisted in the same RedisDB / Append Only file.
关于redis - 如何在redis中实现 Multi-Tenancy ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61313392/