Memcached Protocol

Memcached Protocol

RPC protocol based on memcached 1.

Tip

Support for version 2.3.0 and above

Registering the memcached 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("memcached://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="cache" interface="java.util.Map" group="member" />

Or, connect directly point-to-point:

  1. <dubbo:reference id="cache" interface="java.util.Map" url="memcached://10.20.153.10:11211" />

Custom interfaces can also be used:

  1. <dubbo:reference id="cache" interface="com.foo.CacheService" url="memcached://10.20.153.10:11211" />

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

If the method names do not match the standard method names of memcached, a mapping relationship needs to be configured 3:

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

  1. Memcached is an efficient KV cache server ↩︎

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

  3. Where “p:xxx” is the standard p tag of spring ↩︎

Feedback

Was this page helpful?

Yes No

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