GitXplorerGitXplorer
r

x-ray-http-cache

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
8315f6294faaec33244fbddf9b4a059b23fc2e9d

Release v1.0.2.

rrhalff committed 9 years ago
Unverified
99838a66d4023d2b4bcbde1153e83a0e67eb1f0f

fix example

rrhalff committed 9 years ago
Unverified
7ad581ee46ce6b110b8719bc9886b221023e32b9

Release v1.0.1.

rrhalff committed 9 years ago
Unverified
daf79add7b3a3612d07a12f9db9a91d832f76033

add some keywords

rrhalff committed 9 years ago
Unverified
12f081d4d87e51b5669c8a5bba33a32a9474271d

initial commit

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