以下は、Java Hotgitops クライアントを使用して、クライアント API を使用して HotTEMPLATES サーバーから情報を保存または取得するためにクライアント API を使用する方法に関するサンプルのコードスニペットです。HotTEMPLATES サーバーがデフォルトの場所(localhost:11222)にバインドされていることを前提としています(localhost:11222)。
//API entry point, by default it connects to localhost:11222
CacheContainer cacheContainer = new RemoteCacheManager();
//obtain a handle to the remote default cache
Cache<String, String> cache = cacheContainer.getCache();
//now add something to the cache and make sure it is there
cache.put("car", "ferrari");
assert cache.get("car").equals("ferrari");
//remove the data
cache.remove("car");
assert !cache.containsKey("car") : "Value must have been removed!";
//API entry point, by default it connects to localhost:11222
CacheContainer cacheContainer = new RemoteCacheManager();
//obtain a handle to the remote default cache
Cache<String, String> cache = cacheContainer.getCache();
//now add something to the cache and make sure it is there
cache.put("car", "ferrari");
assert cache.get("car").equals("ferrari");
//remove the data
cache.remove("car");
assert !cache.containsKey("car") : "Value must have been removed!";
Copy to ClipboardCopied!Toggle word wrapToggle overflow