Geo
Look up the geospatial commands, GeoQuery and the result types.
Geo commands store longitude and latitude pairs in a sorted set and search them by radius or box.
Example (Finding Nearby Places)
import { } from "effect";
import { } from "@effect-kit/redis";
import type { } from "@effect-kit/redis";
const : = {
: { : 15, : 37 },
: { : 200, : "km" },
: "ASC",
};
const = .(function* () {
const = yield* ;
yield* .("places", [
{ : 13.361389, : 38.115556, : "palermo" },
{ : 15.087269, : 37.502669, : "catania" },
]);
const near = yield* .("places", , { : true });
return ;
});geosearch returns member names as bytes. geosearchWith returns GeoResult values with the extra details you ask for.
Methods
| Method | Command | Reply type | Purpose |
|---|---|---|---|
redis.geoadd | GEOADD | bigint | Add members with coordinates. |
redis.geopos | GEOPOS | readonly Option<readonly [number, number]>[] | Read member coordinates as longitude and latitude. |
redis.geodist | GEODIST | Option<number> | Return the distance between two members as a number. |
redis.geodistToken | GEODIST | Option<string> | Return the distance as the server's decimal text. |
redis.geohash | GEOHASH | readonly Option<string>[] | Return member geohash strings. |
redis.geosearch | GEOSEARCH | readonly Uint8Array[] | Find members inside a circle or box. |
redis.geosearchWith | GEOSEARCH | readonly GeoResult[] | Find members and include distance, hash or coordinates. |
redis.geosearchstore | GEOSEARCHSTORE | bigint | Store the members found by a search in a key. |
redis.georadius | GEORADIUS | readonly Uint8Array[] | Find members within a radius of a point (older form). |
redis.georadiusRo | GEORADIUS_RO | readonly Uint8Array[] | Find members within a radius of a point without writing. |
redis.georadiusbymember | GEORADIUSBYMEMBER | readonly Uint8Array[] | Find members within a radius of a member (older form). |
redis.georadiusbymemberRo | GEORADIUSBYMEMBER_RO | readonly Uint8Array[] | Find members within a radius of a member without writing. |
redis.georadiusWith | GEORADIUS or GEORADIUSBYMEMBER | readonly GeoResult[] | Radius search with distance, hash or coordinates, from a point or a member. |
redis.georadiusStore | GEORADIUS or GEORADIUSBYMEMBER | bigint | Radius search that stores the result in a key. |
GeoQuery
geosearch, geosearchWith and geosearchstore take a GeoQuery. origin is a member or a point, and area is a circle or a box.
Prop
Type
GeoUnitis"m" | "km" | "ft" | "mi".GeoOriginis theorigintype above.GeoSelectionis{ order?; count? }, used by the oldergeoradiusmethods.GeoDetailsis{ distance?: boolean; hash?: boolean; coordinates?: boolean }, used by theWithmethods.GeoPositionis{ longitude: number; latitude: number; member: string | Uint8Array }.GeoAddOptionsforgeoaddis{ condition?: "NX" | "XX"; changed?: boolean }.
GeoResult is the element of the With replies. Each detail is an Option and is None unless you asked for it.
Prop
Type