Reference the key affinity service
API Following code snippet depicts how a reference to this service can be obtained and used. //1. obtain a reference to a cache manager EmbeddedCacheManager cacheManager = getCacheManager();//obtain a reference to a cache manager Cache cache = cacheManager.getCache(); Â //2. create the affinity service KeyAffinityService keyAffinityService = KeyAffinityServiceFactory.newLocalKeyAffinityService(cache, new RndKeyGenerator(), Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Executors.newSingleThreadExecutor(), 100); Â //3. obtain a key to be mapped to a certain address Object localKey = keyAffinityService.getKeyForAddress(cacheManager.getAddress()); Â //4. this put makes sure that the key resigns on the local node (as obtained cacheManager.getAddress()) cache.put(localKey, "yourValue"); The service is started at step 2: after this point it uses the supplied Excutor to generate and queue keys. At step 3, we obtain a key for this service, and use it at step 4, with that guarantee that it is distributed in node identified by cacheManager.getAddress().