cachedsyncrequest
v1.1.6
Published
Cache addon for node's popular request module
Downloads
5
Maintainers
Readme
Sync + Cached version of Request
Allow you send cached + sync requests. Depends on "syncrequest", "cachedrequest" and "request" module https://github.com/request/request/. No extra configuration needed.
Installation
$ npm install -s cachedsyncrequest
Simple:
var request = require('cachedsyncrequest');
var result = request.cached.sync('http://www.comlog.org');
console.info(result);
Set cache direcotry:
var request = require('cachedsyncrequest');
request.setCacheDirectory('/my/path/to/cache/folder');
var result = request.cached.sync('http://www.comlog.org');
console.info(result);
Clear cache:
var request = require('cachedsyncrequest');
request.setCacheDirectory('/my/path/to/cache/folder');
request.clearCache(function(errors, removed) {
console.error(errors);
console.info(removed);
});
Original request function can be used:
var request = require('cachedsyncrequest');
request.cached.sync('http://www.comlog.org', function(err, response, body) {
console.info(body);
});