org.springframework.data.redis.connection.RedisGeoCommands Java Examples
The following examples show how to use
org.springframework.data.redis.connection.RedisGeoCommands.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracingRedisConnectionTest.java From java-redis-client with Apache License 2.0 | 6 votes |
@Test public void invokingGeoAddCreatesNewSpan() { commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), null, "member".getBytes())); verify(mockRedisConnection()).geoAdd("key".getBytes(), null, "member".getBytes()); commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), (RedisGeoCommands.GeoLocation<byte[]>) null)); verify(mockRedisConnection()) .geoAdd("key".getBytes(), (RedisGeoCommands.GeoLocation<byte[]>) null); commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), (Map<byte[], Point>) null)); verify(mockRedisConnection()).geoAdd("key".getBytes(), (Map<byte[], Point>) null); commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), (Iterable<RedisGeoCommands.GeoLocation<byte[]>>) null)); verify(mockRedisConnection()) .geoAdd("key".getBytes(), (Iterable<RedisGeoCommands.GeoLocation<byte[]>>) null); }
Example #2
Source File: TracingRedisConnectionTest.java From java-redis-client with Apache License 2.0 | 6 votes |
@Test public void invokingGeoRadiusByMemberCreatesNewSpan() { commandCreatesNewSpan(RedisCommand.GEORADIUSBYMEMBER, () -> getConnection().geoRadiusByMember("key".getBytes(), "member".getBytes(), 0D)); verify(mockRedisConnection()).geoRadiusByMember("key".getBytes(), "member".getBytes(), 0D); commandCreatesNewSpan(RedisCommand.GEORADIUSBYMEMBER, () -> getConnection().geoRadiusByMember("key".getBytes(), "member".getBytes(), null)); verify(mockRedisConnection()).geoRadiusByMember("key".getBytes(), "member".getBytes(), null); commandCreatesNewSpan(RedisCommand.GEORADIUSBYMEMBER, () -> getConnection().geoRadiusByMember("key".getBytes(), "member".getBytes(), null, RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs())); verify(mockRedisConnection()) .geoRadiusByMember(eq("key".getBytes()), eq("member".getBytes()), isNull(), any(RedisGeoCommands.GeoRadiusCommandArgs.class)); }
Example #3
Source File: TracingRedisConnectionTest.java From java-redis-client with Apache License 2.0 | 6 votes |
@Test public void invokingGeoAddCreatesNewSpan() { commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), null, "member".getBytes())); verify(mockRedisConnection()).geoAdd("key".getBytes(), null, "member".getBytes()); commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), (RedisGeoCommands.GeoLocation<byte[]>) null)); verify(mockRedisConnection()) .geoAdd("key".getBytes(), (RedisGeoCommands.GeoLocation<byte[]>) null); commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), (Map<byte[], Point>) null)); verify(mockRedisConnection()).geoAdd("key".getBytes(), (Map<byte[], Point>) null); commandCreatesNewSpan(RedisCommand.GEOADD, () -> getConnection().geoAdd("key".getBytes(), (Iterable<RedisGeoCommands.GeoLocation<byte[]>>) null)); verify(mockRedisConnection()) .geoAdd("key".getBytes(), (Iterable<RedisGeoCommands.GeoLocation<byte[]>>) null); }
Example #4
Source File: TracingRedisConnectionTest.java From java-redis-client with Apache License 2.0 | 6 votes |
@Test public void invokingGeoRadiusByMemberCreatesNewSpan() { commandCreatesNewSpan(RedisCommand.GEORADIUSBYMEMBER, () -> getConnection().geoRadiusByMember("key".getBytes(), "member".getBytes(), 0D)); verify(mockRedisConnection()).geoRadiusByMember("key".getBytes(), "member".getBytes(), 0D); commandCreatesNewSpan(RedisCommand.GEORADIUSBYMEMBER, () -> getConnection().geoRadiusByMember("key".getBytes(), "member".getBytes(), null)); verify(mockRedisConnection()).geoRadiusByMember("key".getBytes(), "member".getBytes(), null); commandCreatesNewSpan(RedisCommand.GEORADIUSBYMEMBER, () -> getConnection().geoRadiusByMember("key".getBytes(), "member".getBytes(), null, RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs())); verify(mockRedisConnection()) .geoRadiusByMember(eq("key".getBytes()), eq("member".getBytes()), isNull(), any(RedisGeoCommands.GeoRadiusCommandArgs.class)); }
Example #5
Source File: RedissonReactiveGeoCommands.java From redisson with Apache License 2.0 | 6 votes |
@Override public Flux<CommandResponse<GeoDistCommand, Distance>> geoDist(Publisher<GeoDistCommand> commands) { return execute(commands, command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getFrom(), "From member must not be null!"); Assert.notNull(command.getTo(), "To member must not be null!"); byte[] keyBuf = toByteArray(command.getKey()); byte[] fromBuf = toByteArray(command.getFrom()); byte[] toBuf = toByteArray(command.getTo()); Metric metric = RedisGeoCommands.DistanceUnit.METERS; if (command.getMetric().isPresent()) { metric = command.getMetric().get(); } Mono<Distance> m = write(keyBuf, DoubleCodec.INSTANCE, new RedisCommand<Distance>("GEODIST", new DistanceConvertor(metric)), keyBuf, fromBuf, toBuf, metric.getAbbreviation()); return m.map(v -> new CommandResponse<>(command, v)); }); }
Example #6
Source File: RedissonReactiveGeoCommands.java From redisson with Apache License 2.0 | 6 votes |
@Override public Flux<CommandResponse<GeoDistCommand, Distance>> geoDist(Publisher<GeoDistCommand> commands) { return execute(commands, command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getFrom(), "From member must not be null!"); Assert.notNull(command.getTo(), "To member must not be null!"); byte[] keyBuf = toByteArray(command.getKey()); byte[] fromBuf = toByteArray(command.getFrom()); byte[] toBuf = toByteArray(command.getTo()); Metric metric = RedisGeoCommands.DistanceUnit.METERS; if (command.getMetric().isPresent()) { metric = command.getMetric().get(); } Mono<Distance> m = write(keyBuf, DoubleCodec.INSTANCE, new RedisCommand<Distance>("GEODIST", new DistanceConvertor(metric)), keyBuf, fromBuf, toBuf, metric.getAbbreviation()); return m.map(v -> new CommandResponse<>(command, v)); }); }
Example #7
Source File: RedissonReactiveGeoCommands.java From redisson with Apache License 2.0 | 6 votes |
@Override public Flux<CommandResponse<GeoDistCommand, Distance>> geoDist(Publisher<GeoDistCommand> commands) { return execute(commands, command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getFrom(), "From member must not be null!"); Assert.notNull(command.getTo(), "To member must not be null!"); byte[] keyBuf = toByteArray(command.getKey()); byte[] fromBuf = toByteArray(command.getFrom()); byte[] toBuf = toByteArray(command.getTo()); Metric metric = RedisGeoCommands.DistanceUnit.METERS; if (command.getMetric().isPresent()) { metric = command.getMetric().get(); } Mono<Distance> m = write(keyBuf, DoubleCodec.INSTANCE, new RedisCommand<Distance>("GEODIST", new DistanceConvertor(metric)), keyBuf, fromBuf, toBuf, metric.getAbbreviation()); return m.map(v -> new CommandResponse<>(command, v)); }); }
Example #8
Source File: RedissonConnectionTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testRadiusWithCoords() { connection.geoAdd("key1".getBytes(), new Point(13.361389, 38.115556), "value1".getBytes()); connection.geoAdd("key1".getBytes(), new Point(15.087269, 37.502669), "value2".getBytes()); GeoResults<RedisGeoCommands.GeoLocation<byte[]>> l = connection.geoRadius("key1".getBytes(), new Circle(new Point(15, 37), new Distance(200, RedisGeoCommands.DistanceUnit.KILOMETERS)), RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs().includeCoordinates()); assertThat(l.getContent()).hasSize(2); assertThat(l.getContent().get(0).getContent().getName()).isEqualTo("value1".getBytes()); assertThat(l.getContent().get(0).getContent().getPoint().toString()).isEqualTo(new Point(13.361389, 38.115556).toString()); assertThat(l.getContent().get(1).getContent().getName()).isEqualTo("value2".getBytes()); assertThat(l.getContent().get(1).getContent().getPoint().toString()).isEqualTo(new Point(15.087267, 37.502668).toString()); GeoResults<RedisGeoCommands.GeoLocation<byte[]>> l2 = connection.geoRadius("key1".getBytes(), new Circle(new Point(15, 37), new Distance(200, RedisGeoCommands.DistanceUnit.KILOMETERS)), RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs()); assertThat(l2.getContent()).hasSize(2); assertThat(l2.getContent().get(0).getContent().getName()).isEqualTo("value1".getBytes()); assertThat(l2.getContent().get(1).getContent().getName()).isEqualTo("value2".getBytes()); }
Example #9
Source File: RedissonReactiveGeoCommands.java From redisson with Apache License 2.0 | 6 votes |
@Override public Flux<CommandResponse<GeoDistCommand, Distance>> geoDist(Publisher<GeoDistCommand> commands) { return execute(commands, command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getFrom(), "From member must not be null!"); Assert.notNull(command.getTo(), "To member must not be null!"); byte[] keyBuf = toByteArray(command.getKey()); byte[] fromBuf = toByteArray(command.getFrom()); byte[] toBuf = toByteArray(command.getTo()); Metric metric = RedisGeoCommands.DistanceUnit.METERS; if (command.getMetric().isPresent()) { metric = command.getMetric().get(); } Mono<Distance> m = write(keyBuf, DoubleCodec.INSTANCE, new RedisCommand<Distance>("GEODIST", new DistanceConvertor(metric)), keyBuf, fromBuf, toBuf, metric.getAbbreviation()); return m.map(v -> new CommandResponse<>(command, v)); }); }
Example #10
Source File: TracingRedisConnectionTest.java From java-redis-client with Apache License 2.0 | 5 votes |
@Test public void invokingGeoRadiusCreatesNewSpan() { commandCreatesNewSpan(RedisCommand.GEORADIUS, () -> getConnection().geoRadius("key".getBytes(), null)); verify(mockRedisConnection()).geoRadius("key".getBytes(), null); commandCreatesNewSpan(RedisCommand.GEORADIUS, () -> getConnection().geoRadius("key".getBytes(), null, RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs())); verify(mockRedisConnection()).geoRadius(eq("key".getBytes()), isNull(), any(RedisGeoCommands.GeoRadiusCommandArgs.class)); }
Example #11
Source File: TracingRedisConnectionTest.java From java-redis-client with Apache License 2.0 | 5 votes |
@Test public void invokingGeoRadiusCreatesNewSpan() { commandCreatesNewSpan(RedisCommand.GEORADIUS, () -> getConnection().geoRadius("key".getBytes(), null)); verify(mockRedisConnection()).geoRadius("key".getBytes(), null); commandCreatesNewSpan(RedisCommand.GEORADIUS, () -> getConnection().geoRadius("key".getBytes(), null, RedisGeoCommands.GeoRadiusCommandArgs.newGeoRadiusArgs())); verify(mockRedisConnection()).geoRadius(eq("key".getBytes()), isNull(), any(RedisGeoCommands.GeoRadiusCommandArgs.class)); }
Example #12
Source File: RedissonConnectionTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testRadius() { connection.geoAdd("key1".getBytes(), new Point(13.361389, 38.115556), "value1".getBytes()); connection.geoAdd("key1".getBytes(), new Point(15.087269, 37.502669), "value2".getBytes()); GeoResults<RedisGeoCommands.GeoLocation<byte[]>> l = connection.geoRadius("key1".getBytes(), new Circle(new Point(15, 37), new Distance(200, RedisGeoCommands.DistanceUnit.KILOMETERS))); assertThat(l.getContent()).hasSize(2); assertThat(l.getContent().get(0).getContent().getName()).isEqualTo("value1".getBytes()); assertThat(l.getContent().get(1).getContent().getName()).isEqualTo("value2".getBytes()); }
Example #13
Source File: TaxiController.java From Spring-Boot-2.0-Projects with MIT License | 4 votes |
@GetMapping public Flux<TaxiAvailableResponseDTO> getAvailableTaxis(@RequestParam("type") TaxiType taxiType, @RequestParam("latitude") Double latitude, @RequestParam("longitude") Double longitude, @RequestParam(value = "radius", defaultValue = "1") Double radius) { Flux<GeoResult<RedisGeoCommands.GeoLocation<String>>> availableTaxisFlux = taxiService.getAvailableTaxis(taxiType, latitude, longitude, radius); return availableTaxisFlux.map(r -> new TaxiAvailableResponseDTO(r.getContent().getName())); }
Example #14
Source File: TaxiService.java From Spring-Boot-2.0-Projects with MIT License | 4 votes |
public Flux<GeoResult<RedisGeoCommands.GeoLocation<String>>> getAvailableTaxis(TaxiType taxiType, Double latitude, Double longitude, Double radius) { return reactiveRedisTemplate.opsForGeo().radius(taxiType.toString(), new Circle(new Point(longitude, latitude), new Distance(radius, Metrics.KILOMETERS))); }
Example #15
Source File: TaxiBookingService.java From Spring-Boot-2.0-Projects with MIT License | 4 votes |
public Flux<GeoResult<RedisGeoCommands.GeoLocation<String>>> getBookings(TaxiType taxiType, Double latitude, Double longitude, Double radius) { return reactiveRedisTemplate.opsForGeo().radius(getTaxiTypeBookings(taxiType), new Circle(new Point(longitude, latitude), new Distance(radius, Metrics.KILOMETERS))); }
Example #16
Source File: TracingRedisConnection.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public RedisGeoCommands geoCommands() { return connection.geoCommands(); }