Skip to content
This repository has been archived by the owner on Jul 4, 2019. It is now read-only.

Commit

Permalink
added memory caching option to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas J Mather committed Dec 24, 2004
1 parent fec4459 commit 8fa9816
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions LookupService.cs
Expand Up @@ -50,8 +50,8 @@ public class LookupService{
private static int US_OFFSET = 1;
private static int CANADA_OFFSET = 677;
private static int WORLD_OFFSET = 1353;
private static int GEOIP_STANDARD = 0;
private static int GEOIP_MEMORY_CACHE = 1;
public static int GEOIP_STANDARD = 0;
public static int GEOIP_MEMORY_CACHE = 1;

private static String[] countryCode = {
"--","AP","EU","AD","AE","AF","AG","AI","AL","AM","AN","AO","AQ","AR",
Expand Down
9 changes: 9 additions & 0 deletions README
Expand Up @@ -25,5 +25,14 @@ mono cityExample.exe
for org example
mono orgExample.exe

MEMORY CACHING

There are two options available:

GEOIP_STANDARD - read database from filesystem, uses least memory.

GEOIP_MEMORY_CACHE - load database into memory, faster performance
but uses more memory

Copyright 2004 MaxMind LLC
Licensed under the GPL
2 changes: 1 addition & 1 deletion cityExample.cs
Expand Up @@ -4,7 +4,7 @@
class Appa0{
public static void Main(String[] args){
//open the database
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPCity.dat");
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPCity.dat", LookupService.GEOIP_STANDARD);
//get city location of the ip address
Location l = ls.getLocation("24.24.24.24");
Console.Write("country code " + l.countryCode + "\n");
Expand Down
2 changes: 1 addition & 1 deletion countryExample.cs
Expand Up @@ -9,7 +9,7 @@
class Appa0{
public static void Main(String[] args){
//open the database
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIP.dat");
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIP.dat", LookupService.GEOIP_MEMORY_CACHE);
//get country of the ip address
Country c = ls.getCountry("24.24.24.24");
Console.Write(" code: " + c.getCode()+"\n");
Expand Down
2 changes: 1 addition & 1 deletion orgExample.cs
Expand Up @@ -4,7 +4,7 @@
class Appa0{
public static void Main(String[] args){
//open the database
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPOrg.dat");
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPOrg.dat", LookupService.GEOIP_STANDARD);
//get org of the ip address
String orgorisp = ls.getOrg("24.24.24.24");
Console.Write(" org: " + orgorisp + "\n");
Expand Down
2 changes: 1 addition & 1 deletion regionExample.cs
Expand Up @@ -4,7 +4,7 @@
class Appa0{
public static void Main(String[] args){
//open the database
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPRegion.dat");
LookupService ls = new LookupService("/usr/local/share/GeoIP/GeoIPRegion.dat", LookupService.GEOIP_STANDARD);
//get region of the ip address
Region c = ls.getRegion("24.24.24.24");
Console.Write(" code: " + c.getcountryCode()+"\n");
Expand Down

0 comments on commit 8fa9816

Please sign in to comment.