Which is quicker? Memcache or file query? (using maxmind geoip.dat file)
- by tomcritchlow
Hi, I'm using Python on Appengine and am looking up the geolocation of an IP address like this:
import pygeoip
gi = pygeoip.GeoIP('GeoIP.dat')
Location = gi.country_code_by_addr(self.request.remote_addr)
(pygeoip can be found here: http://code.google.com/p/pygeoip/)
I want to geolocate each page of my app for a user so currently I lookup the IP address once then store it in memcache.
My question - which is quicker? Looking up the IP address each time from the .dat file or fetching it from memcache? Are there any other pros/cons I need to be aware of?
For general queries like this, is there a good guide to teach me how to optimise my code and run speed tests myself? I'm new to python and coding in general so apologies if this is a basic concept.
Thanks!
Tom