For the latest stable version, please use Spring Data Redis 3.4.0!spring-doc.cn

Redis Repositories Running on a 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.spring-doc.cn

The following table shows the details of data on a cluster (based on previous examples):spring-doc.cn

Key Type Slot Node

people:e2c7dcee-b8cd-4424-883e-736ce564363espring-doc.cn

id for hashspring-doc.cn

15171spring-doc.cn

127.0.0.1:7381spring-doc.cn

people:a9d4b3a0-50d3-4538-a2fc-f7fc2581ee56spring-doc.cn

id for hashspring-doc.cn

7373spring-doc.cn

127.0.0.1:7380spring-doc.cn

people:firstname:randspring-doc.cn

indexspring-doc.cn

1700spring-doc.cn

127.0.0.1:7379spring-doc.cn

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):spring-doc.cn

Key Type Slot Node

{people}:e2c7dcee-b8cd-4424-883e-736ce564363espring-doc.cn

id for hashspring-doc.cn

2399spring-doc.cn

127.0.0.1:7379spring-doc.cn

{people}:a9d4b3a0-50d3-4538-a2fc-f7fc2581ee56spring-doc.cn

id for hashspring-doc.cn

2399spring-doc.cn

127.0.0.1:7379spring-doc.cn

{people}:firstname:randspring-doc.cn

indexspring-doc.cn

2399spring-doc.cn

127.0.0.1:7379spring-doc.cn

Define and pin keyspaces by using @RedisHash("{yourkeyspace}") to specific slots when you use Redis cluster.