dnscacheNode.js 緩存代理
dnscache for Node 封裝了 Node.js 的 dns 模塊方法,在這之間提供緩存層。每個(gè)到 dns 方法的調(diào)用看起來都是本地緩存。dnscache 非常類似 GOF Proxy 設(shè)計(jì)模式,提供一個(gè)緩存代理。
dnscache 主要目標(biāo)是緩存大部分 dns 調(diào)用,避免網(wǎng)絡(luò)延遲,提升性能。
安裝
npm install dnscache
使用
var dns = require('dns'),
dnscache = require('dnscache')({
"enable" : true,
"ttl" : 300,
"cachesize" : 1000
});
//to use the cached dns either of dnscache or dns can be called.
//all the methods of dns are wrapped, this one just shows lookup on an example
//will call the wrapped dns
dnscache.lookup('www.yahoo.com', function(err, result) {
//do something with result
});
//will call the wrapped dns
dns.lookup('www.google.com', function(err, result) {
//do something with result
});
配置
-
enable -
ttl -
cachesize -
cache
評(píng)論
圖片
表情
