node-stream-cache

Stream things into a redis cache

Usage no npm install needed!

<script type="module">
  import nodeStreamCache from 'https://cdn.skypack.dev/node-stream-cache';
</script>

README

node-stream-cache

Stream things in and out of a redis cache

Example

var Cache = require('./index.js')
  , cacher = new Cache
  , request = require('request')
  , JSONStream = require('JSONStream')
  , es = require('event-stream')

var work = function () {
  var parser = JSONStream.parse(['rows', true])
    , req = request({url: 'http://isaacs.couchone.com/registry/_all_docs'})

  req.pipe(parser)
  return parser
}

var done = function (stream) {
  stream.pipe(es.mapSync(function (data) {
                console.error(data)
                return data
              }))
}

cacher.process('docs', work, done, 60)