Redis implementation
Redis implementation
Requirements
Redis SortedSet
# This is how we set Redis sorted set for a given object location belonging to a Geo-Hash prefix:
$ ZADD key score member
$ ZADD geo_hash_prefix current_timestamp object_id
# Example:
$ ZADD 6e10h 1603013034 7619
$ ZADD 6e10h 1603013050 2781
$ ZADD a72b8 1603013089 9082
# Let's say our expiry time is 30 seconds, so just before retrieving current objects for a request belonging to a Geo-Hash prefix, we can delete all data older than current timestamp - 30 seconds, this way, expiration will happen gradually over time:
$ ZREMRANGEBYSCORE geo_hash_prefix -INF current_timestamp - 30 seconds
# -INF = Redis understands it as the lowest valueLast updated
Was this helpful?