Redis Protocol

Redis Protocol

RPC protocol implemented based on Redis 1.

Tip

Supports versions above 2.3.0

Register Redis Service Address

  1. RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension();
  2. Registry registry = registryFactory.getRegistry(URL.valueOf("zookeeper://10.20.153.10:2181"));
  3. registry.register(URL.valueOf("redis://10.20.153.11/com.foo.BarService?category=providers&dynamic=false&application=foo&group=member&loadbalance=consistenthash"));

Referencing on the Client Side

Use on the client side 2:

  1. <dubbo:reference id="store" interface="java.util.Map" group="member" />

Alternatively, point-to-point direct connection:

  1. <dubbo:reference id="store" interface="java.util.Map" url="redis://10.20.153.10:6379" />

You can also use a custom interface:

  1. <dubbo:reference id="store" interface="com.foo.StoreService" url="redis://10.20.153.10:6379" />

It is recommended that the method names match the standard Redis method names, namely: get(key), set(key, value), delete(key).

If the method names differ from the standard Redis method names, you will need to configure the mapping 3:

  1. <dubbo:reference id="cache" interface="com.foo.CacheService" url="redis://10.20.153.10:6379" p:set="putFoo" p:get="getFoo" p:delete="removeFoo" />

  1. Redis is an efficient KV storage server ↩︎

  2. No need to be aware of the Redis address ↩︎

  3. Where “p:xxx” is the standard p tag in Spring ↩︎

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)