Node.js 缓存代理 dnscache

码农软件 · 软件分类 · Node.js 扩展 · 2019-04-14 17:42:51

软件介绍

dnscache for Node 封装了 Node.js 的 dns 模块方法,在这之间提供缓存层。每个到 dns 方法的调用看起来都是本地缓存。dnscache 非常类似 GOF Proxy 设计模式,提供一个缓存代理。

dnscache 主要目标是缓存大部分 dns 调用,避免网络延迟,提升性能。

安装

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

本文地址:https://codercto.com/soft/d/3579.html

了不起的Node.js

了不起的Node.js

劳奇 (Guillermo Rauch) / 赵静 / 电子工业出版社 / 2014-1 / 79.00元

本书是一本经典的 Learning by Doing的书籍。它由 Node社区著名的 Socket.IO作者—— Guillermo Rauch,通过大量的实践案例撰写,并由 Node社区非常活跃的开发者—— Goddy Zhao翻译而成。 本书内容主要由对五大部分的介绍组成: Node核心设计理念、 Node核心模块 API、Web开发、数据库以及测试。从前到后、由表及里地对使用 Node......一起来看看 《了不起的Node.js》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具