5

I'm trying to use the MaxMind GeoIP database, and I notice that the C API provides a bunch of different cacheing modes as flags to the GeoIP_open initialization call.

  • GEOIP_MEMORY_CACHE
  • GEOIP_CHECK_CACHE
  • GEOIP_INDEX_CACHE
  • GEOIP_MMAP_CACHE

these are flag bits, so you can provide any set of them, but there's no documentation as to what these flags mean or what they do, or (perhaps most important) how they interact.

The benchmarks page indicates that GEOIP_MEMORY_CACHE makes it faster while GEOIP_CHECK_CACHE makes it slower, but there's no indication as to why you would want to use (or not use) any of these flags.

1 Answer 1

4

Their github page describes the purpose of these caches.

GEOIP_STANDARD - Read database from file system. This uses the least memory.
GEOIP_MEMORY_CACHE - Load database into memory. Provides faster performance but uses more memory.
GEOIP_CHECK_CACHE - Check for updated database. If database has been updated, reload file handle and/or memory cache.
GEOIP_INDEX_CACHE - Cache only the the most frequently accessed index portion of the database, resulting in faster lookups than GEOIP_STANDARD, but less memory usage than GEOIP_MEMORY_CACHE. This is useful for larger databases such as GeoIP Organization and GeoIP City. Note: for GeoIP Country, Region and Netspeed databases, GEOIP_INDEX_CACHE is equivalent to GEOIP_MEMORY_CACHE.
GEOIP_MMAP_CACHE - Load database into mmap shared memory. MMAP is not available for 32bit Windows.

These options can be combined using bit operators. For example you can use both GEOIP_MEMORY_CACHE and GEOIP_CHECK_CACHE by calling: GeoIP_open("/path/to/GeoIP.dat", GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE);

Click to know more information

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.