GitXplorerGitXplorer
r

x-ray-http-cache

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
b961b56468a360ee132ebfa5e7ffe56001978576

update

rrhalff committed 9 years ago
Unverified
140994299d2d46abdca8bdefb8ed4af86e32f795

make superagent instance optional and do not require it (#1)

rrhalff committed 9 years ago
Unverified
4694936233c73a30d342ae9a50d3f23aadba4340

test and linting

rrhalff committed 9 years ago
Unverified
d4b9ff08f3c6fbb9f4875c3fde87dd6072cc8f88

add test dependencies

rrhalff committed 9 years ago
Unverified
9cbeb119ac8f46d0b46b7c95bcba2ef45ac2fcf4

include redis in test

rrhalff committed 9 years ago
Unverified
1589807f2a3ece6ee7a675beba79072c96450e47

add travis

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