owntracks / recorder

Store and access data published by OwnTracks apps
Other
820 stars 120 forks source link

Expire cached reverse geo data after TTL #447

Closed jpmens closed 4 months ago

jpmens commented 4 months ago

When the recorder performs a reverse geo lookup for a particular lat/lon (a.k.a. geohash) combination we store the address (and since recently tzname) in the database.

In the course of time, that address might be invalidated, e.g. a street is renamed. (It's even possible that a time zone is renamed.)

The proposal is to add something like a ttl to the cached data and periodically purge expired entries.

jpmens commented 4 months ago

It takes less than 1 second to scan through 120,000 records in the lmdb geocache using a cursor in a running recorder, including reading the record and decoding its JSON:

START: 1707256233
COUNT= 120112
END: 1707256233

This would make it feasable to keep it all very simple and, say, perform a scan every 10 or 20 received positions to determine which of the cached entries need purging and purge them.