I'm using the Redis Geo API to store positions, then i fetch them with GEORADIUS.
Since i can only set latitude, longitude and a name for each location, how i can store and retrieve other data when i fetch locations with GEORADIUS?
First thing that come in my mind was to use GEOADD name as a key, and then store additional data in a normal key/value set, with the key being the same as name, fetch the array of positions with GEORADIUS, and loop trough that array and fetch other data using name as key.
Is this the correct approach or there is a better way to do that?
If the other data needs to be updated/accessed, storing it in a different key (usually a Hash) makes sense. However, if the other data per name is immutable and accessed only in conjugation to the geo querying, you can just "embed" it after the name, e.g.:
GEOADD geoset lon lat name:data1:data2:...:datan
Of course, when getting the query's reply you'll have to "decode" the results and break each one back into its constituting components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With