2.1.3 • Published 4 years ago

redistub v2.1.3

Weekly downloads
56
License
MIT
Repository
github
Last release
4 years ago

redistub

A Redis shell with no state, meant for testing controllers which check cache before using a model.

Build Status Coverage Status npm version Dependency Status

Install

$ npm install redistub --save

Run the specs

$ npm test

Supported Redis client API stubs

createClient

Creates a new stateless API.

var redis       = require('redistub'),
    redisClient = redis.createClient();

// Now use redisClient as you intend to in production and write your tests to assume redis is offline.

createClient -> get

Normally used to get an item from the Redis store, this method will always return null for both err and val

var redis       = require('redistub'),
    redisClient = redis.createClient();

redisClient.get('someCacheKey', function(err, val) {
  // err will always be null
  // val will always be null
});

createClient -> mget

Normally used to get an array of items from the Redis store, this method will always return null for both err and val

var redis       = require('redistub'),
    redisClient = redis.createClient();

redisClient.mget(['someCacheKey', 'someOtherCacheKey'], function(err, val) {
  // err will always be null
  // val will always be null
});

createClient -> set

Normally used to set an item in the Redis store, this method will always return null for err and OK for res

var redis       = require('redistub'),
    redisClient = redis.createClient();

redisClient.set('someCacheKey', 'someVal', function(err, res) {
  // err will always be null
  // res will always be OK
});

createClient -> expire

Normally used to set an expiration ttl for an item in the Redis store, this method will always return null for err and 1 for affectedItems

var redis       = require('redistub'),
    redisClient = redis.createClient();

redisClient.expire('someCacheKey', 3600, function(err, affectedItems) {
  // err will always be null
  // affectedItems will always be 1
});

createClient -> del

Normally used to remove an item from the Redis store, this method will always return null for err and 1 for affectedItems

var redis       = require('redistub'),
    redisClient = redis.createClient();

redisClient.del('someCacheKey', 'someVal', function(err, affectedItems) {
  // err will always be null
  // affectedItems will always be 1
});
2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

6 years ago

2.1.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

9 years ago