Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ private List<byte[]> sendMultiGet(List<RedisKey> keys) {
.boxed()
.collect(Collectors.toList());

if (indexMissingValue.isEmpty()) {
return redisValues;
}

byte[][] fallbackBinaryKeys =
indexMissingValue.stream()
.map(i -> fallbackSerializer.serialize(keys.get(i)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;

import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -147,7 +147,9 @@ public void shouldReturnResponseWithValuesIfKeysPresent() {
List<KeyValue<byte[], byte[]>> featureRowBytes = Lists.newArrayList(keyValue1, keyValue2);

OnlineRetriever redisClusterOnlineRetriever =
new RedisClusterOnlineRetriever.Builder(connection, serializer).build();
new RedisClusterOnlineRetriever.Builder(connection, serializer)
.withFallbackSerializer(fallbackSerializer)
.build();
when(syncCommands.mget(serializedKey1, serializedKey2)).thenReturn(featureRowBytes);

List<Optional<FeatureRow>> expected =
Expand All @@ -174,6 +176,9 @@ public void shouldReturnResponseWithValuesIfKeysPresent() {
List<Optional<FeatureRow>> actual =
redisClusterOnlineRetriever.getOnlineFeatures(entityRows, featureSetRequest);
assertThat(actual, equalTo(expected));

// check that fallback is used only when there's something to fallback
verify(syncCommands, never()).mget();
}

@Test
Expand Down