Sharing Routes between multiple Gateway instances

Spring Cloud Gateway 提供了两种 RouteDefinitionRepository 实现。第一个是 InMemoryRouteDefinitionRepository,它只存在于一个 Gateway 实例的内存中。这种类型的仓库不适合用于跨多个 Gateway 实例填充路由。

为了跨 Spring Cloud Gateway 实例集群共享路由,可以使用 RedisRouteDefinitionRepository。要启用这种类型的仓库,必须将以下属性设置为 true:spring.cloud.gateway.redis-route-definition-repository.enabled。与 RedisRateLimiter Filter Factory 类似,它需要使用 spring-boot-starter-data-redis-reactive Spring Boot Starter。