Skip to main content

Usage

Parameters

key
string
required
The key to store the geospatial index.
member
GeoMember | GeoMember[]
required
One or more geospatial members to add. Each member includes:
options
GeoAddCommandOptions
Optional configuration:

Response

result
number | null
The number of elements added to the sorted set (not including elements already existing for which the score was updated).Returns null when used with xx or nx options and the conditions are not met.

Examples

Add a single location

Add multiple locations

Only add new locations (nx)

Update existing locations only (xx)

Important Notes

Coordinate Order

Redis stores geospatial data as a sorted set using the Geohash technique. The coordinate order is longitude first, then latitude:

Valid Ranges

  • Longitude: -180 to 180 degrees
  • Latitude: -85.05112878 to 85.05112878 degrees
Coordinates outside these ranges will return an error.