GEOADD to add longitude, latitude, and member triples to a geospatial index.
Each position is encoded into a 52-bit geohash and stored as the score of the member in a sorted set, so a geospatial key is an ordinary sorted set and commands such as ZREM, ZCARD, and ZSCAN work on it. Longitude must be between -180 and 180 and latitude between -85.05112878 and 85.05112878; anything outside those bounds returns an error. Adding a member that is already present moves it to the new position, and the encoding means coordinates read back with GEOPOS are very close to, but not exactly, the ones you stored.
NX only adds members that are not there yet, XX only updates members that already exist, and CH makes the reply count every member that changed rather than only the ones that were added.
Syntax
Arguments
Important points
NXandXXare mutually exclusive.
Response
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples
TCP examples use the TLSREDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
upstash_redis
upstash_redis
ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs