Permalink
Browse files

updated readme, version bump

  • Loading branch information...
1 parent 596c8a7 commit 455676d4d8a78dc303d9cc0c9a9aa940a260ce3f @runk committed Mar 25, 2013
Showing with 46 additions and 13 deletions.
  1. +36 −4 README.md
  2. +8 −7 benchmark.js
  3. +2 −2 package.json
View
@@ -27,19 +27,51 @@ You can download free geo databases here: http://dev.maxmind.com/geoip/geolite.
City/Location lookup
+```js
var maxmind = require('maxmind');
- maxmind.init('/path/to/GeoLiteCity.dat')
+ maxmind.init('/path/to/GeoLiteCity.dat');
console.log(maxmind.getLocation("66.6.44.4"));
+```
Country Lookup
+```js
var maxmind = require('maxmind');
- maxmind.init('/path/to/GeoIP.dat')
+ maxmind.init('/path/to/GeoIP.dat');
console.log(maxmind.getCountry("66.6.44.4"));
+```
+
+## Caching
+
+By default module does not use cache, and works directly with file system. Enabling cache
+leads to better performance, howerver consumer more memory. Currently module supports two options:
+
+- `indexCache` saves in memory only the country index
+- `memoryCache` saves in memory full database file
+
+If you decided to enable caching you can pass it as a flag in `init` method:
+
+```js
+ var maxmind = require('maxmind');
+ maxmind.init('/path/to/GeoIP.dat', { indexCache: true });
+```
+
+Caching could significantly increase performance, refer to this camparison which was made on average
+laptop:
+
+- default: 18,000 lookups / second
+- `indexCache`: 60,000 lookups / second
+- `memodyCache`: 100,000 lookups / second
+
+## Tests
+
+If you want ot run tests you will need `mocha` installed, then just run it:
+
+ $ mocha
+
## Disclaimer
-Module is quite young and some serious bugs are possible. Feel free to
+Module is quite young and serious bugs are possible. Feel free to
send pull request / bug reports.
-Module currently work only in `MEMORY_CACHE` mode.
View
@@ -2,10 +2,17 @@
var fs = require('fs');
var ls = require('./lib/lookup_service');
+function randip() {
+ return [
+ Math.floor(Math.random() * 255),
+ Math.floor(Math.random() * 255),
+ Math.floor(Math.random() * 255),
+ Math.floor(Math.random() * 255)
+ ].join('.');
+}
ls.init('./test/dbs/GeoLiteCity.dat');
var ips = fs.readFileSync('./test/dbs/ips.txt');
-
ips = ips.toString().split("\n").map(function(line) {
return line.trim();
});
@@ -20,9 +27,3 @@ for (var i = ips.length - 1; i >= 0; i--) {
console.log('n: ', n);
console.log('time:', (new Date().getTime() - s), "msec");
console.log('speed:', Math.round(n / (new Date().getTime() - s) * 1000), 'per sec');
-
-// console.log(ls.dump())
-
-// var time = process.hrtime();
-// var diff = process.hrtime(time);
-// console.log((diff[0] * 1e9 + diff[1]) / 1e9);
View
@@ -1,9 +1,9 @@
{
"name": "maxmind",
- "version": "0.0.5",
+ "version": "0.1.0",
"homepage": "https://github.com/runk/node-maxmind",
"description": "IP lookup using Maxmind databases",
- "keywords": ["maxmind", "geo", "geobase", "geo lookup", "ip base", "geocode"],
+ "keywords": ["maxmind", "geo", "geobase", "geo lookup", "ip base", "geocode", "timezone"],
"author": "Shirokov Dmitry <deadrunk@gmail.com>",
"dependencies": {},
"repository": {

0 comments on commit 455676d

Please sign in to comment.