第2章 組み込みモードでの実行
インメモリーデータストレージ用に、プロジェクトに Data Grid ライブラリーを埋め込みます。
2.1. EmbeddedCacheManager Bean の追加 リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
infinispan-spring-boot-starter-embeddedをプロジェクトのクラスパスに追加して、組み込みモードを有効にします。このスターターは、デフォルトでクラスパス上の
infinispan-spring-boot-starter-remoteで、リモートクライアント/サーバーモードで動作します。次の例のように、Spring の
@Autowiredアノテーションを使用して、Java 設定クラスにEmbeddedCacheManagerBeanを含めます。Copy to Clipboard Copied! Toggle word wrap Toggle overflow これで、組み込みモードで Data Grid を使用できるようになりました。以下は簡単な例です。
cacheManager.getCache("testCache").put("testKey", "testValue"); System.out.println("Received value from cache: " + cacheManager.getCache("testCache").get("testKey"));cacheManager.getCache("testCache").put("testKey", "testValue"); System.out.println("Received value from cache: " + cacheManager.getCache("testCache").get("testKey"));Copy to Clipboard Copied! Toggle word wrap Toggle overflow