If anyone wants something similar I built a version of this a few weeks ago:
https://github.com/contrast/geoip_sinatraIt's a sinatra app which uses the MaxMind data, typically responds in < 1ms, and it has caching built in (if you deploy it to heroku).