Hot Rod エンドポイントを使用したリモートキャッシュでの読み取り操作および書き込み操作は、デフォルトでクライアントマーシャラーを使用します。Hot Rod は、異なるメディアタイプエンコーディングやマーシャラーを使用してキャッシュ操作を実行するのに使用できる Java クライアントの DataFormat API を提供します。
キーと値の異なるマーシャラー
実行時にキーと値のマーシャラーを上書きできます。
たとえば、Hot Rod クライアントのすべてのシリアル化をバイパスし、リモートキャッシュに保存されている byte[] 配列を読み取るには、以下を実行します。
// Existing RemoteCache instance
RemoteCache<String, Pojo> remoteCache = ...
// IdentityMarshaller is a no-op marshaller
DataFormat rawKeyAndValues =
DataFormat.builder()
.keyMarshaller(IdentityMarshaller.INSTANCE)
.valueMarshaller(IdentityMarshaller.INSTANCE)
.build();
// Creates a new instance of RemoteCache with the supplied DataFormat
RemoteCache<byte[], byte[]> rawResultsCache =
remoteCache.withDataFormat(rawKeyAndValues);
// Existing RemoteCache instance
RemoteCache<String, Pojo> remoteCache = ...
// IdentityMarshaller is a no-op marshaller
DataFormat rawKeyAndValues =
DataFormat.builder()
.keyMarshaller(IdentityMarshaller.INSTANCE)
.valueMarshaller(IdentityMarshaller.INSTANCE)
.build();
// Creates a new instance of RemoteCache with the supplied DataFormat
RemoteCache<byte[], byte[]> rawResultsCache =
remoteCache.withDataFormat(rawKeyAndValues);
Copy to ClipboardCopied!Toggle word wrapToggle overflow