Redis Protocol

Redis Protocol

RPC protocol implemented based on Redis 1.

Register Redis Service Address

RegistryFactory registryFactory = ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension();
Registry registry = registryFactory.getRegistry(URL.valueOf("zookeeper://10.20.153.10:2181"));
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:

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

Alternatively, point-to-point direct connection:

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

You can also use a custom interface:

<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:

<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 ↩︎