Cache the database
petekcchen opened this issue · 3 comments
Hi,
Is there any suggested practice to cache the database (the one I'm using is GeoIP2-Country.mmdb)?
What I would like to do is, when my web applications launch, I cache the database so that for every coming requests, I can look up the cache directly instead of instantiate DatabaseReader every time. And if there's updated database, I can overwrite the old one while my applications are still running.
Would that be possible? Thanks.
Yes. The DatabaseReader
is thread-safe. You can share it across threads without issue and replace it with a new one when you updated the database.
If I use maxmind/geoipupdate to automatically update the DB, will DatabaseReader detect the change and reload the DB files? Or do I need to restart the app after updating?
You will need to reopen the reader.