2013-08-26 13 views
5

Sto tentando di utilizzare il database MaxMind GeoIP e ho notato che l'API C fornisce una serie di diverse modalità di cache come flag alla chiamata di inizializzazione GeoIP_open.Che cosa significano le varie modalità di memorizzazione nella cache di MaxMind GeoIP?

  • GEOIP_MEMORY_CACHE
  • GEOIP_CHECK_CACHE
  • GEOIP_INDEX_CACHE
  • GEOIP_MMAP_CACHE

questi sono bandiera bit, in modo da poter fornire qualsiasi insieme di essi, ma non c'è alcuna documentazione su ciò che significano queste bandiere o cosa fanno, o (forse la cosa più importante) in che modo interagiscono.

Il benchmarks page indica che GEOIP_MEMORY_CACHE lo rende più veloce, mentre GEOIP_CHECK_CACHE rende più lento, ma non c'è alcuna indicazione sul motivo per cui si desidera utilizzare (o non utilizzare) qualsiasi di queste bandiere.

risposta

4

La loro pagina github descrive lo scopo di queste cache.

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. 

Queste opzioni possono essere combinate utilizzando gli operatori di bit. Ad esempio, puoi utilizzare sia GEOIP_MEMORY_CACHE che GEOIP_CHECK_CACHE chiamando: GeoIP_open ("/ percorso/a/GeoIP.dat", GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE);

Click to know more information