GitXplorerGitXplorer
r

x-ray-http-cache

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
b323e6a9af71e54aeb976cdccfe13fa4c7b27908

Release v2.0.0.

rrhalff committed 9 years ago
Unverified
fb42bdcf3b7ac1faa31c8aa73f141c13edfa0114

allow for proxy to be set

rrhalff committed 9 years ago
Unverified
c9a08194db3f42997a6e8621a198e22a379388b8

Release v1.1.1.

rrhalff committed 9 years ago
Unverified
71b506bef4489deb8c1ebd66801d75fc0020b958

more descriptive function name

rrhalff committed 9 years ago
Unverified
8ad2cf78175e1ef4a02ddf5c2544c0747d8c6d0d

Release v1.1.0.

rrhalff committed 9 years ago
Unverified
78e1a8fa7b1ec5dc5144778beecd3fcdc7e65fa1

track uptodateness

rrhalff committed 9 years ago

README

The README file for this repository.

x-ray-http-cache

TravisCI Build Status NPM version Dependency Status Development Dependency Status

http-cache driver for x-ray.

Uses superagent-cache for caching.

See it's documentation for supported caching drivers.

Installation

npm install x-ray-http-cache --save

Usage

var httpCache = require('x-ray-http-cache');

// using redis for caching
var redisModule = require('cache-service-redis');

var redisCache = new redisModule({
  redisUrl: 'http://localhost:6379'
});

var Xray = require('x-ray');

var x = Xray()
  .driver(httpCache({
    driver: redisCache,

    cacheWhenEmpty: false,
    expiration: 86400, // 24 hours

    // Optional: provide own superagent instance
    // superagent: require('superagent')
  }));

x('http://google.com', 'title')(function(err, str) {
  console.log('Google', str);

  // close connection to redis when finished
  redisCache.db.quit();
});

Throttle

It's currently not possible to determine whether or not to throttle based on cache.

However if you are sure the cache is already populated you can reset throttling using:

x.throttle(Infinity, 0);

License

MIT