Redis Repositories Running on a Cluster
在集群式 Redis 环境中,你可以使用 Redis 存储库支持。有关 ConnectionFactory
配置的详细信息,请参考 “Redis Cluster” 部分。尽管如此,仍需执行一些额外的配置,因为默认键分配会将实体和辅助索引分散到整个集群及其插槽中。
You can use the Redis repository support in a clustered Redis environment.
See the “Redis Cluster” section for ConnectionFactory
configuration details.
Still, some additional configuration must be done, because the default key distribution spreads entities and secondary indexes through out the whole cluster and its slots.
下表显示了有关集群中数据的详细信息(基于前面的示例):
The following table shows the details of data on a cluster (based on previous examples):
Key | Type | Slot | Node |
---|---|---|---|
people:e2c7dcee-b8cd-4424-883e-736ce564363e |
id for hash |
15171 |
127.0.0.1:7381 |
people:a9d4b3a0-50d3-4538-a2fc-f7fc2581ee56 |
id for hash |
7373 |
127.0.0.1:7380 |
people:firstname:rand |
index |
1700 |
127.0.0.1:7379 |
当所有涉及的键映射到相同的时隙时,某些命令(如 SINTER
和 SUNION
)只能在服务器端处理。否则,必须在客户端完成计算。因此,将键空间固定到某个时隙很有用,这可以立刻利用 Redis 服务器端的计算。下表显示执行此操作时会发生什么(注意时隙列中的更改和节点列中的端口值):
Some commands (such as SINTER
and SUNION
) can only be processed on the server side when all involved keys map to the same slot.
Otherwise, computation has to be done on client side.
Therefore, it is useful to pin keyspaces to a single slot, which lets make use of Redis server side computation right away.
The following table shows what happens when you do (note the change in the slot column and the port value in the node column):
Key | Type | Slot | Node |
---|---|---|---|
{people}:e2c7dcee-b8cd-4424-883e-736ce564363e |
id for hash |
2399 |
127.0.0.1:7379 |
{people}:a9d4b3a0-50d3-4538-a2fc-f7fc2581ee56 |
id for hash |
2399 |
127.0.0.1:7379 |
{people}:firstname:rand |
index |
2399 |
127.0.0.1:7379 |
使用 |
Define and pin keyspaces by using |