Polishing.
Use createMono/createFlux syntax instead of using the template for wrapper creation. See #2658 Original pull request: #2659
This commit is contained in:
@@ -26,7 +26,6 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.data.geo.Circle;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.GeoResult;
|
||||
@@ -276,7 +275,7 @@ class DefaultReactiveGeoOperations<K, V> implements ReactiveGeoOperations<K, V>
|
||||
Assert.notNull(reference, "GeoReference must not be null");
|
||||
GeoReference<ByteBuffer> rawReference = getGeoReference(reference);
|
||||
|
||||
return template.doCreateFlux(connection -> connection.geoCommands()
|
||||
return createFlux(geoCommands -> geoCommands
|
||||
.geoSearch(rawKey(key), rawReference, geoPredicate, args).map(this::readGeoResult));
|
||||
}
|
||||
|
||||
@@ -288,7 +287,7 @@ class DefaultReactiveGeoOperations<K, V> implements ReactiveGeoOperations<K, V>
|
||||
Assert.notNull(reference, "GeoReference must not be null");
|
||||
GeoReference<ByteBuffer> rawReference = getGeoReference(reference);
|
||||
|
||||
return template.doCreateMono(connection -> connection.geoCommands().geoSearchStore(rawKey(destKey), rawKey(key),
|
||||
return createMono(geoCommands -> geoCommands.geoSearchStore(rawKey(destKey), rawKey(key),
|
||||
rawReference, geoPredicate, args));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.data.redis.connection.ReactiveHashCommands;
|
||||
import org.springframework.data.redis.connection.convert.Converters;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
@@ -127,8 +126,7 @@ class DefaultReactiveHashOperations<H, HK, HV> implements ReactiveHashOperations
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> connection //
|
||||
.hashCommands().hRandField(rawKey(key))).map(this::readHashKey);
|
||||
return createMono(hashCommands -> hashCommands.hRandField(rawKey(key))).map(this::readHashKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,8 +134,7 @@ class DefaultReactiveHashOperations<H, HK, HV> implements ReactiveHashOperations
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> connection //
|
||||
.hashCommands().hRandFieldWithValues(rawKey(key))).map(this::deserializeHashEntry);
|
||||
return createMono(hashCommands ->hashCommands.hRandFieldWithValues(rawKey(key))).map(this::deserializeHashEntry);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,8 +142,7 @@ class DefaultReactiveHashOperations<H, HK, HV> implements ReactiveHashOperations
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateFlux(connection -> connection //
|
||||
.hashCommands().hRandField(rawKey(key), count)).map(this::readHashKey);
|
||||
return createFlux(hashCommands -> hashCommands.hRandField(rawKey(key), count)).map(this::readHashKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.function.Function;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.springframework.data.redis.connection.BitFieldSubCommands;
|
||||
import org.springframework.data.redis.connection.ReactiveNumberCommands;
|
||||
import org.springframework.data.redis.connection.ReactiveStringCommands;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
@@ -200,7 +201,7 @@ class DefaultReactiveValueOperations<K, V> implements ReactiveValueOperations<K,
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> connection.numberCommands().incr(rawKey(key)));
|
||||
return createNumericMono(numberCommands -> numberCommands.incr(rawKey(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,7 +209,7 @@ class DefaultReactiveValueOperations<K, V> implements ReactiveValueOperations<K,
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> connection.numberCommands().incrBy(rawKey(key), delta));
|
||||
return createNumericMono(numberCommands -> numberCommands.incrBy(rawKey(key), delta));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,7 +217,7 @@ class DefaultReactiveValueOperations<K, V> implements ReactiveValueOperations<K,
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> connection.numberCommands().incrBy(rawKey(key), delta));
|
||||
return createNumericMono(numberCommands -> numberCommands.incrBy(rawKey(key), delta));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,7 +225,7 @@ class DefaultReactiveValueOperations<K, V> implements ReactiveValueOperations<K,
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> connection.numberCommands().decr(rawKey(key)));
|
||||
return createNumericMono(numberCommands -> numberCommands.decr(rawKey(key)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,7 +233,7 @@ class DefaultReactiveValueOperations<K, V> implements ReactiveValueOperations<K,
|
||||
|
||||
Assert.notNull(key, "Key must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> connection.numberCommands().decrBy(rawKey(key), delta));
|
||||
return createNumericMono(numberCommands -> numberCommands.decrBy(rawKey(key), delta));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,6 +304,13 @@ class DefaultReactiveValueOperations<K, V> implements ReactiveValueOperations<K,
|
||||
return template.doCreateMono(connection -> connection.keyCommands().del(rawKey(key))).map(l -> l != 0);
|
||||
}
|
||||
|
||||
private <T> Mono<T> createNumericMono(Function<ReactiveNumberCommands, Publisher<T>> function) {
|
||||
|
||||
Assert.notNull(function, "Function must not be null");
|
||||
|
||||
return template.doCreateMono(connection -> function.apply(connection.numberCommands()));
|
||||
}
|
||||
|
||||
private <T> Mono<T> createMono(Function<ReactiveStringCommands, Publisher<T>> function) {
|
||||
|
||||
Assert.notNull(function, "Function must not be null");
|
||||
|
||||
Reference in New Issue
Block a user