I am using the new geospatial features on Redis. I know that behind the scene it's using ZSET.
I am adding new entries this way:
GEOADD" "report-geo-set" "4.78335244" "32.07223969" "jossef"
How could I add an expire to a specific records(in my case: "jossef")
on my set?
If the API doesnt provide it is there any workaround for this?
Thanks, ray.
Regrettably no - Redis expires entire keys and not the values in their respective data structures. Geo Hashes are implemented on top Sorted Sets and expiration of individual members isn't supported.
What you could do is maintain an additional Sorted Set and for each member in it store the expiration timestamp as score. Then, periodically, fetch the members that need to be expired from it based on ZRANGEBYSCORE and "manually" ZREM the respective members from your Geo Hash.
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