diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-12-14 14:40:00 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-12-14 14:40:00 -0800 |
commit | 7b1c0c40133f198d47936366730108721029f90b (patch) | |
tree | eec9485a52e80f53129db86a8dce311c8eb31106 /cluster-geo | |
parent | f558b088e6c62c3531ce3e85f28c9284f0898971 (diff) | |
download | infinitytier-7b1c0c40133f198d47936366730108721029f90b.tar.gz infinitytier-7b1c0c40133f198d47936366730108721029f90b.zip |
Cache null results from Maxmind.
Diffstat (limited to 'cluster-geo')
-rw-r--r-- | cluster-geo/cluster-geo/cluster-geo.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/cluster-geo/cluster-geo/cluster-geo.js b/cluster-geo/cluster-geo/cluster-geo.js index 3cbc60be..bbb78e1f 100644 --- a/cluster-geo/cluster-geo/cluster-geo.js +++ b/cluster-geo/cluster-geo/cluster-geo.js @@ -32,11 +32,9 @@ function lookup(ip,callback) if (cachedEntry) { let ts = cachedEntry.ts; let r = cachedEntry.r; - if ((ts)&&(r)) { - if ((Date.now() - ts) < CACHE_TTL) { - r._cached = true; + if (ts) { + if ((Date.now() - ts) < CACHE_TTL) return callback(null,r); - } } } } catch (e) {} @@ -45,8 +43,8 @@ function lookup(ip,callback) geo(ip,function(err,result) { if (err) return callback(err,null); - if ((!result)||(!result.location)) - return callback(new Error('null result'),null); + if (!result) + result = null; cache.put(ip,JSON.stringify({ ts: Date.now(), |