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"));
在客户端使用 3:
<dubbo:reference id="store" interface="java.util.Map" group="member" />
或者,点对点直连:
<dubbo:reference id="store" interface="java.util.Map" url="redis://10.20.153.10:6379" />
也可以使用自定义接口:
<dubbo:reference id="store" interface="com.foo.StoreService" url="redis://10.20.153.10:6379" />
方法名建议和 redis 的标准方法名相同,即:get(key), set(key, value), delet(key)。
如果方法名和 redis 的标准方法名不相同,则需要配置映射关系 4:
<dubbo:reference id="cache" interface="com.foo.CacheService" url="memcached://10.20.153.10:11211" p:set="putFoo" p:get="getFoo" p:delete="removeFoo" />