public class GeolocationCache extends Object
It caches all IPs with their matching country.
This cache uses the Google Guava Cache
.
Modifier and Type | Method and Description |
---|---|
static void |
checkDB()
Checks if the DB exists, if not, it downloads it
|
static void |
clearCache()
Clears the cache
|
static String |
getCountry(String ipAddress)
Retrieves the country in full length (e.g.
|
static boolean |
isCached(String ipAddress)
Checks if the IP Address is cached
|
public static String getCountry(String ipAddress)
This method uses the geolocationCache
, every first access is getting cached and then retrieved later.
ipAddress
- The IP Address from which the country is retrievedAn exception from that rule is when the country is unknown or the retrieval of the country failed in any way, if that happens, "Not Known" will be returned.
getUnCachedCountry(String)
public static void checkDB() throws IOException
IOException
- when an error at download or saving the DB happenspublic static boolean isCached(String ipAddress)
ipAddress
- The IP Address which is checkedpublic static void clearCache()
Copyright © 2017. All rights reserved.