Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including memory-cache-stream with all npm packages installed. Try it out:

var memoryCacheStream = require("memory-cache-stream")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

memory-cache-stream v1.2.0

In-memory cache modeled after node_redis api with additional streaming support.


NPM Version NPM Downloads Build Status Test Coverage

In-memory cache implementing a subset of the node-redis API - specifically the get, set, setex, exists, del, flushall, and ttl commands. Like node_redis, all commands can take an optional callback as the final argument.

This cache isn't really intended for production scenarios, but is suitable for use in place of node_redis for development environments and unit tests.

In addition to the subset of the built-in Redis commands, there are 3 additional functions: readStream, writeStream, and writeThrough that are used to stream data into and out of the cache. Although these are purely for backwards API compatibility since the cached strings are already in memory.

For the real Redis, checkout the redis-streams package augments RedisClient with these same functions.


npm install memory-cache-stream 


var memoryCache = require('memory-cache-stream');

// Set with ttl of 1 minute
memoryCache.setex(key, 60, 'some string to cache');

// Get using a callback
memoryCache.get(key, function(err, data) {

// Pipe out of the cache

// Pipe into a cache
    .pipe(memoryCache.writeStream(key, 60))
    .on('finish', done);

// Pipe into the cache and through to stdout
    .pipe(memoryCache.writeThrough(key, 60))

See the unit tests for additional examples.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free