Skip to content

Rename Function Lambda parameter to match command interface in (Default) ReactiveXxxOperations #2659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.2.0-GH-2658-SNAPSHOT</version>

<name>Spring Data Redis</name>
<description>Spring Data module for Redis</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Mono<Long> add(K key, Point point, V member) {
Assert.notNull(point, "Point must not be null");
Assert.notNull(member, "Member must not be null");

return createMono(connection -> connection.geoAdd(rawKey(key), point, rawValue(member)));
return createMono(geoCommands -> geoCommands.geoAdd(rawKey(key), point, rawValue(member)));
}

@Override
Expand All @@ -77,7 +77,7 @@ public Mono<Long> add(K key, GeoLocation<V> location) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(location, "GeoLocation must not be null");

return createMono(connection -> connection.geoAdd(rawKey(key),
return createMono(geoCommands -> geoCommands.geoAdd(rawKey(key),
new GeoLocation<>(rawValue(location.getName()), location.getPoint())));
}

Expand All @@ -87,13 +87,13 @@ public Mono<Long> add(K key, Map<V, Point> memberCoordinateMap) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(memberCoordinateMap, "MemberCoordinateMap must not be null");

return createMono(connection -> {
return createMono(geoCommands -> {

Mono<List<GeoLocation<ByteBuffer>>> serializedList = Flux
.fromIterable(() -> memberCoordinateMap.entrySet().iterator())
.map(entry -> new GeoLocation<>(rawValue(entry.getKey()), entry.getValue())).collectList();

return serializedList.flatMap(list -> connection.geoAdd(rawKey(key), list));
return serializedList.flatMap(list -> geoCommands.geoAdd(rawKey(key), list));
});
}

Expand All @@ -103,12 +103,12 @@ public Mono<Long> add(K key, Iterable<GeoLocation<V>> geoLocations) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(geoLocations, "GeoLocations must not be null");

return createMono(connection -> {
return createMono(geoCommands -> {

Mono<List<GeoLocation<ByteBuffer>>> serializedList = Flux.fromIterable(geoLocations)
.map(location -> new GeoLocation<>(rawValue(location.getName()), location.getPoint())).collectList();

return serializedList.flatMap(list -> connection.geoAdd(rawKey(key), list));
return serializedList.flatMap(list -> geoCommands.geoAdd(rawKey(key), list));
});
}

Expand All @@ -118,11 +118,11 @@ public Flux<Long> add(K key, Publisher<? extends Collection<GeoLocation<V>>> loc
Assert.notNull(key, "Key must not be null");
Assert.notNull(locations, "Locations must not be null");

return createFlux(connection -> Flux.from(locations)
return createFlux(geoCommands -> Flux.from(locations)
.map(locationList -> locationList.stream()
.map(location -> new GeoLocation<>(rawValue(location.getName()), location.getPoint()))
.collect(Collectors.toList()))
.flatMap(list -> connection.geoAdd(rawKey(key), list)));
.flatMap(list -> geoCommands.geoAdd(rawKey(key), list)));
}

@Override
Expand All @@ -132,7 +132,7 @@ public Mono<Distance> distance(K key, V member1, V member2) {
Assert.notNull(member1, "Member 1 must not be null");
Assert.notNull(member2, "Member 2 must not be null");

return createMono(connection -> connection.geoDist(rawKey(key), rawValue(member1), rawValue(member2)));
return createMono(geoCommands -> geoCommands.geoDist(rawKey(key), rawValue(member1), rawValue(member2)));
}

@Override
Expand All @@ -143,7 +143,7 @@ public Mono<Distance> distance(K key, V member1, V member2, Metric metric) {
Assert.notNull(member2, "Member 2 must not be null");
Assert.notNull(metric, "Metric must not be null");

return createMono(connection -> connection.geoDist(rawKey(key), rawValue(member1), rawValue(member2), metric));
return createMono(geoCommands -> geoCommands.geoDist(rawKey(key), rawValue(member1), rawValue(member2), metric));
}

@Override
Expand All @@ -152,7 +152,7 @@ public Mono<String> hash(K key, V member) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(member, "Member must not be null");

return createMono(connection -> connection.geoHash(rawKey(key), rawValue(member)));
return createMono(geoCommands -> geoCommands.geoHash(rawKey(key), rawValue(member)));
}

@Override
Expand All @@ -163,10 +163,10 @@ public final Mono<List<String>> hash(K key, V... members) {
Assert.notEmpty(members, "Members must not be null or empty");
Assert.noNullElements(members, "Members must not contain null elements");

return createMono(connection -> Flux.fromArray(members) //
return createMono(geoCommands -> Flux.fromArray(members) //
.map(this::rawValue) //
.collectList() //
.flatMap(serialized -> connection.geoHash(rawKey(key), serialized)));
.flatMap(serialized -> geoCommands.geoHash(rawKey(key), serialized)));
}

@Override
Expand All @@ -175,7 +175,7 @@ public Mono<Point> position(K key, V member) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(member, "Member must not be null");

return createMono(connection -> connection.geoPos(rawKey(key), rawValue(member)));
return createMono(geoCommands -> geoCommands.geoPos(rawKey(key), rawValue(member)));
}

@Override
Expand All @@ -186,10 +186,10 @@ public final Mono<List<Point>> position(K key, V... members) {
Assert.notEmpty(members, "Members must not be null or empty");
Assert.noNullElements(members, "Members must not contain null elements");

return createMono(connection -> Flux.fromArray(members) //
return createMono(geoCommands -> Flux.fromArray(members) //
.map(this::rawValue) //
.collectList() //
.flatMap(serialized -> connection.geoPos(rawKey(key), serialized)));
.flatMap(serialized -> geoCommands.geoPos(rawKey(key), serialized)));
}

@Override
Expand All @@ -198,7 +198,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, Circle within) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(within, "Circle must not be null");

return createFlux(connection -> connection.geoRadius(rawKey(key), within).map(this::readGeoResult));
return createFlux(geoCommands -> geoCommands.geoRadius(rawKey(key), within).map(this::readGeoResult));
}

@Override
Expand All @@ -208,7 +208,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, Circle within, GeoRadiusCom
Assert.notNull(within, "Circle must not be null");
Assert.notNull(args, "GeoRadiusCommandArgs must not be null");

return createFlux(connection -> connection.geoRadius(rawKey(key), within, args) //
return createFlux(geoCommands -> geoCommands.geoRadius(rawKey(key), within, args) //
.map(this::readGeoResult));
}

Expand All @@ -218,8 +218,9 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, double radius) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(member, "Member must not be null");

return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), new Distance(radius)) //
.map(this::readGeoResult));
return createFlux(geoCommands ->
geoCommands.geoRadiusByMember(rawKey(key), rawValue(member), new Distance(radius)) //
.map(this::readGeoResult));
}

@Override
Expand All @@ -229,7 +230,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance
Assert.notNull(member, "Member must not be null");
Assert.notNull(distance, "Distance must not be null");

return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), distance) //
return createFlux(geoCommands -> geoCommands.geoRadiusByMember(rawKey(key), rawValue(member), distance) //
.map(this::readGeoResult));
}

Expand All @@ -241,7 +242,7 @@ public Flux<GeoResult<GeoLocation<V>>> radius(K key, V member, Distance distance
Assert.notNull(distance, "Distance must not be null");
Assert.notNull(args, "GeoRadiusCommandArgs must not be null");

return createFlux(connection -> connection.geoRadiusByMember(rawKey(key), rawValue(member), distance, args))
return createFlux(geoCommands -> geoCommands.geoRadiusByMember(rawKey(key), rawValue(member), distance, args))
.map(this::readGeoResult);
}

Expand Down Expand Up @@ -308,8 +309,7 @@ private <T> Flux<T> createFlux(Function<ReactiveGeoCommands, Publisher<T>> funct
@SuppressWarnings("unchecked")
private GeoReference<ByteBuffer> getGeoReference(GeoReference<V> reference) {
return reference instanceof GeoReference.GeoMemberReference
? GeoReference
.fromMember(rawValue(((GeoMemberReference<V>) reference).getMember()))
? GeoReference.fromMember(rawValue(((GeoMemberReference<V>) reference).getMember()))
: (GeoReference<ByteBuffer>) reference;
}

Expand All @@ -327,7 +327,7 @@ private V readValue(ByteBuffer buffer) {

private GeoResult<GeoLocation<V>> readGeoResult(GeoResult<GeoLocation<ByteBuffer>> source) {

return new GeoResult<>(new GeoLocation(readValue(source.getContent().getName()), source.getContent().getPoint()),
return new GeoResult<>(new GeoLocation<>(readValue(source.getContent().getName()), source.getContent().getPoint()),
source.getDistance());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public Mono<Long> remove(H key, Object... hashKeys) {
Assert.notEmpty(hashKeys, "Hash keys must not be empty");
Assert.noNullElements(hashKeys, "Hash keys must not contain null elements");

return createMono(connection -> Flux.fromArray(hashKeys) //
return createMono(hashCommands -> Flux.fromArray(hashKeys) //
.map(o -> (HK) o).map(this::rawHashKey) //
.collectList() //
.flatMap(hks -> connection.hDel(rawKey(key), hks)));
.flatMap(hks -> hashCommands.hDel(rawKey(key), hks)));
}

@Override
Expand All @@ -73,7 +73,7 @@ public Mono<Boolean> hasKey(H key, Object hashKey) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(hashKey, "Hash key must not be null");

return createMono(connection -> connection.hExists(rawKey(key), rawHashKey((HK) hashKey)));
return createMono(hashCommands -> hashCommands.hExists(rawKey(key), rawHashKey((HK) hashKey)));
}

@Override
Expand All @@ -83,7 +83,8 @@ public Mono<HV> get(H key, Object hashKey) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(hashKey, "Hash key must not be null");

return createMono(connection -> connection.hGet(rawKey(key), rawHashKey((HK) hashKey)).map(this::readHashValue));
return createMono(hashCommands ->
hashCommands.hGet(rawKey(key), rawHashKey((HK) hashKey)).map(this::readHashValue));
}

@Override
Expand All @@ -93,10 +94,10 @@ public Mono<List<HV>> multiGet(H key, Collection<HK> hashKeys) {
Assert.notNull(hashKeys, "Hash keys must not be null");
Assert.notEmpty(hashKeys, "Hash keys must not be empty");

return createMono(connection -> Flux.fromIterable(hashKeys) //
return createMono(hashCommands -> Flux.fromIterable(hashKeys) //
.map(this::rawHashKey) //
.collectList() //
.flatMap(hks -> connection.hMGet(rawKey(key), hks)).map(this::deserializeHashValues));
.flatMap(hks -> hashCommands.hMGet(rawKey(key), hks)).map(this::deserializeHashValues));
}

@Override
Expand Down Expand Up @@ -162,7 +163,7 @@ public Flux<HK> keys(H key) {

Assert.notNull(key, "Key must not be null");

return createFlux(connection -> connection.hKeys(rawKey(key)) //
return createFlux(hashCommands -> hashCommands.hKeys(rawKey(key)) //
.map(this::readHashKey));
}

Expand All @@ -171,7 +172,7 @@ public Mono<Long> size(H key) {

Assert.notNull(key, "Key must not be null");

return createMono(connection -> connection.hLen(rawKey(key)));
return createMono(hashCommands -> hashCommands.hLen(rawKey(key)));
}

@Override
Expand All @@ -180,9 +181,9 @@ public Mono<Boolean> putAll(H key, Map<? extends HK, ? extends HV> map) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(map, "Map must not be null");

return createMono(connection -> Flux.fromIterable(() -> map.entrySet().iterator()) //
return createMono(hashCommands -> Flux.fromIterable(() -> map.entrySet().iterator()) //
.collectMap(entry -> rawHashKey(entry.getKey()), entry -> rawHashValue(entry.getValue())) //
.flatMap(serialized -> connection.hMSet(rawKey(key), serialized)));
.flatMap(serialized -> hashCommands.hMSet(rawKey(key), serialized)));
}

@Override
Expand All @@ -192,7 +193,7 @@ public Mono<Boolean> put(H key, HK hashKey, HV value) {
Assert.notNull(hashKey, "Hash key must not be null");
Assert.notNull(value, "Hash value must not be null");

return createMono(connection -> connection.hSet(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
return createMono(hashCommands -> hashCommands.hSet(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
}

@Override
Expand All @@ -202,15 +203,15 @@ public Mono<Boolean> putIfAbsent(H key, HK hashKey, HV value) {
Assert.notNull(hashKey, "Hash key must not be null");
Assert.notNull(value, "Hash value must not be null");

return createMono(connection -> connection.hSetNX(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
return createMono(hashCommands -> hashCommands.hSetNX(rawKey(key), rawHashKey(hashKey), rawHashValue(value)));
}

@Override
public Flux<HV> values(H key) {

Assert.notNull(key, "Key must not be null");

return createFlux(connection -> connection.hVals(rawKey(key)) //
return createFlux(hashCommands -> hashCommands.hVals(rawKey(key)) //
.map(this::readHashValue));
}

Expand All @@ -219,7 +220,7 @@ public Flux<Map.Entry<HK, HV>> entries(H key) {

Assert.notNull(key, "Key must not be null");

return createFlux(connection -> connection.hGetAll(rawKey(key)) //
return createFlux(hashCommands -> hashCommands.hGetAll(rawKey(key)) //
.map(this::deserializeHashEntry));
}

Expand All @@ -229,7 +230,7 @@ public Flux<Map.Entry<HK, HV>> scan(H key, ScanOptions options) {
Assert.notNull(key, "Key must not be null");
Assert.notNull(key, "ScanOptions must not be null");

return createFlux(connection -> connection.hScan(rawKey(key), options) //
return createFlux(hashCommands -> hashCommands.hScan(rawKey(key), options) //
.map(this::deserializeHashEntry));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public final Mono<Long> add(K key, V... values) {
Assert.notEmpty(values, "Values must not be null or empty");
Assert.noNullElements(values, "Values must not contain null elements");

return createMono(connection -> Flux.fromArray(values) //
return createMono(hyperLogLogCommands -> Flux.fromArray(values) //
.map(this::rawValue) //
.collectList() //
.flatMap(serializedValues -> connection.pfAdd(rawKey(key), serializedValues)));
.flatMap(serializedValues -> hyperLogLogCommands.pfAdd(rawKey(key), serializedValues)));
}

@Override
Expand All @@ -66,10 +66,10 @@ public final Mono<Long> size(K... keys) {
Assert.notEmpty(keys, "Keys must not be null or empty");
Assert.noNullElements(keys, "Keys must not contain null elements");

return createMono(connection -> Flux.fromArray(keys) //
return createMono(hyperLogLogCommands -> Flux.fromArray(keys) //
.map(this::rawKey) //
.collectList() //
.flatMap(connection::pfCount));
.flatMap(hyperLogLogCommands::pfCount));
}

@Override
Expand All @@ -80,10 +80,10 @@ public final Mono<Boolean> union(K destination, K... sourceKeys) {
Assert.notEmpty(sourceKeys, "Source keys must not be null or empty");
Assert.noNullElements(sourceKeys, "Source keys must not contain null elements");

return createMono(connection -> Flux.fromArray(sourceKeys) //
return createMono(hyperLogLogCommands -> Flux.fromArray(sourceKeys) //
.map(this::rawKey) //
.collectList() //
.flatMap(serialized -> connection.pfMerge(rawKey(destination), serialized)));
.flatMap(serialized -> hyperLogLogCommands.pfMerge(rawKey(destination), serialized)));
}

@Override
Expand Down
Loading