alex-plekhanov commented on code in PR #13002:
URL: https://github.com/apache/ignite/pull/13002#discussion_r3062766623
##########
docs/_docs/code-snippets/java/src/main/java/org/apache/ignite/snippets/WorkingWithBinaryObjects.java:
##########
@@ -142,6 +142,45 @@ public static void configuringBinaryObjects() {
}
+ //tag::keepBinaryWithCacheInterceptor[]
+ public static void cacheWithInterceptorExample() {
+ try (Ignite ignite = Ignition.start()) {
+ CacheConfiguration specConfig = new
CacheConfiguration("personSpecCache");
+ ccfg.setInterceptor(new CustomInterceptor(false));
+ IgniteCache<Integer, Person> cache = ignite.createCache(ccfg);
+ cache.put(1, new Person(1, "FirstPerson"));
+
+ CacheConfiguration boConfig = new
CacheConfiguration("boSpecCache");
+ ccfg.setInterceptor(new CustomInterceptor(true));
+ IgniteCache<Integer, Person> cache = ignite.createCache(ccfg);
+ cache = cache.withKeepBinary();
+ cache.put(1, new Person(1, "FirstPerson"));
+ }
+ }
+
+ private static class CustomInterceptor implements CacheInterceptor<Object,
Object> {
+ boolean keepBinary;
+
+ CustomInterceptor(boolean keepBinary) {
+ this.keepBinary = keepBinary;
+ }
+
+ @Nullable @Override public Object onBeforePut(Cache.Entry<Object,
Object> entry, Object newVal) {
+ assertEquals(keepBinary, newVal instanceof BinaryObject);
Review Comment:
assertEquals is a part of JUnit framework, шт "examples" let's use `assert`
instead
##########
modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java:
##########
@@ -33,6 +33,9 @@
* Cache interceptor is configured via {@link
CacheConfiguration#getInterceptor()}
* configuration property.
* <p>
+ * The type of incoming values depends on cache operation types, that is, the
{@link IgniteCache#withKeepBinary()}
Review Comment:
For me `cache operation types` are `put`, `get`, etc. Maybe some other
description of `keepBinary`? `cache options`? `cache modifiers`? `runtime cache
configuration`? `cache operation context` (like in private API)?
##########
docs/_docs/key-value-api/binary-objects.adoc:
##########
@@ -177,6 +177,21 @@ tab:C#/.NET[unsupported]
tab:C++[unsupported]
--
+== Interaction with CacheInterceptor
+`CacheInterceptor` also take into account cache `keepBinary` mode and process
a value appropriately.
+
+[tabs]
+--
+tab:Java[]
+[source,java]
+----
+include::{javaCodeDir}/WorkingWithBinaryObjects.java[tag=keepBinaryWithCacheInterceptor,indent=0]
+----
+
+tab:C#/.NET[unsupported]
+
+tab:C++[unsupported]
Review Comment:
I think this section can be included to `Enabling Binary Mode for Caches`,
since it refer to `keepBinary`. But there are couple of sections between these
sections now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]