diff --git a/lib/unshortener.js b/lib/unshortener.js index 351de2d..5273178 100644 --- a/lib/unshortener.js +++ b/lib/unshortener.js @@ -6,6 +6,7 @@ var hash = require('node_hash'); var options = {}; var memclient; +var urlLifetime = 1000; var map = { bitly: { 'hosts': ['bit.ly', 'j.mp', 'ericri.es', 'jc.is', 'nyti.ms', 'rww.to', 'linkd.in', 'win.gs', 'dai.ly', 'imgry.net', 'mln.im', 'theatln.tc', 'rvtra.de', 'amzn.to'], @@ -41,6 +42,9 @@ exports.config = function(opts) { if (typeof(opts.proxy) !== 'undefined') { request.defaults({'proxy':opts.proxy}); } + if (typeof(opts.urlLifetime) !== 'undefined') { + urlLifetime = opts.urlLifetime; + } } exports.expand = function (url, opts, callback) { @@ -73,7 +77,7 @@ exports.expand = function (url, opts, callback) { exports.saveUrl = function(url,result) { if (memclient) { result = (typeof(result) !== 'undefined') ? result : url; - memclient.set( hash.sha256(url.href), JSON.stringify(result), 1000); + memclient.set( hash.sha256(url.href), JSON.stringify(result), urlLifetime); } };