scope ipToCountry2020. sS #dataSnippetID = #1400400; static Map #cache = mruCache(100); static Lock #lock = lock(); static File #dataDir() { ret javaxCachesDir("ipToCountry2020"); } sS ipToCountry2020(S ip) { ret ipToCountry2020(ipToInt(ip)); } sS ipToCountry2020(long ipNum) { ret mapGetOrCreate(cache, ipNum, () -> uncached(ipNum)); } sS #uncached(long ipNum) { { lock lock; if (directoryEmpty(dataDir())) unzipSnippet(dataSnippetID, dataDir()); } S line = pairB(binarySearchForLineInTextFile(newFile(dataDir(), "IP2LOCATION-LITE-DB1.CSV"), s -> { LS l = tok_splitAtComma_unquote(s); long a = parseLongOpt(first(l)), b = parseLongOpt(second(l)); ifdef ipToCountry2020_debug printVars_str("ipToCountry2020: ", +a, +b, +ipNum); endifdef ret ipNum > b ? 1 : ipNum < a ? -1 : 0; })); ret get(tok_splitAtComma_unquote(line), 2); }