ioredis-mock

Emulates ioredis by performing all operations in-memory.

MIT License

Downloads
2.8M
Stars
326
Committers
91

Bot releases are visible (Hide)

ioredis-mock - v3.6.4

Published by stipsan over 6 years ago

  • Fixed: keys no longer returns empty sets, just like real redis (#358)
ioredis-mock - v3.6.3

Published by stipsan over 6 years ago

  • Fixed: srandom not using Set. (#356 @ianmuninio)
ioredis-mock - v3.6.2

Published by stipsan over 6 years ago

  • Fixed: DEL should return number of keys deleted from the data, not the number of arguments (#355 @donaldjarmstrong)
ioredis-mock - v3.6.1

Published by stipsan almost 7 years ago

  • Fixed: Passing null values should not throw exceptions (#353 @kkragenbrink)
ioredis-mock - v3.6.0

Published by stipsan almost 7 years ago

Added

ZRANGEBYSCORE command (#350 @usebaz)

const data = {
  foo: new Map([
    ['first', { score: 1, value: 'first' }],
    ['second', { score: 2, value: 'second' }],
    ['third', { score: 3, value: 'third' }],
    ['fourth', { score: 4, value: 'fourth' }],
    ['fifth', { score: 5, value: 'fifth' }],
  ]),
};
const RedisMock = require('ioredis-mock');
const redis = new RedisMock({ data });
redis
  .zrangebyscore('foo', 1, 3)
  .then(result => console.log(result)) // logs ['first', 'second', 'third']

QUIT stub (#350 @usebaz)

In ioredis this is the equivalent to calling redis.disconnect. ioredis-mock does not implement connection simulation functionality yet so for now it's just a stub.

redis.quit() // OK

UNSUBSCRIBE stub (#350 @usebaz)

Our previous release added subscribe and joining the fray you can now pretend to be unsubscribing (just like the newsletters in your inbox!)

redis.unsubscribe() // OK
ioredis-mock - v3.5.0

Published by stipsan almost 7 years ago

Added

Subscribe Stub (#348 @yitongding)

const RedisMock = require('ioredis-mock');
const redis = new RedisMock();
redis.subscribe('news', 'music').then(result => console.log(result)) // logs '2'
ioredis-mock - v3.4.2

Published by stipsan almost 7 years ago

  • Fixed: Remove .eslintcache file from package (#347)
ioredis-mock - v3.4.1

Published by stipsan almost 7 years ago

  • Fixed: More detailed RunKit example (#346)
ioredis-mock - v3.4.0

Published by stipsan almost 7 years ago

Added

Full Argument and Reply transformer support (#342 @DrMegavolt)

Any transformer you use on arguments and replies in ioredis will work in ioredis-mock 🎉

Since we're now able to load the built in transformers in ioredis we could finally get rid of old code related to the the hgetall and hmset commands.

If you're using ioredis-mock standalone and haven't upgraded to v3.3.0 or newer

The following only apply if you use ioredis-mock without installing ioredis

If this is your use case you'll need to install ioredis as well or ioredis-mock will not work as we're using ioredis internals to stay compatible. Using ioredis-mock without installing ioredis have been possible up to now but's newer actually been officially supported. That's why ioredis have always been specified as a peerDependency.

ioredis-mock - v3.3.1

Published by stipsan almost 7 years ago

  • Fixed: Missing runkit file (#340)
ioredis-mock - v3.3.0

Published by stipsan almost 7 years ago

Added

Added support for passing Map and Object to hmset

This is a stopgap solution until real argument and reply transformers is implemented and fully compatible with ioredis

ZADD command (#321 @ddunkin)

redis.zadd('myzset', '1', 'one', '1', 'uno',  '2', 'two', '3', 'three') // returns `4` as 4 items got added

ZRANGE command (#321 @ddunkin)

redis.zrange('myzset', 0, -1) // ['one', 'uno', 'two', 'three']

ZREVRANGE command (#321 @ddunkin)

redis.zrevrange('myzset', 0, -1) // ['three', 'two', 'uno', 'one']

ZREMRANGEBYRANK command (#321 @ddunkin)

redis.zremrangebyrank('myzset', 0, 2) // returns '3' as that’s how many items got deleted
redis.zrange('myzset', 0, -1) // ['three']
ioredis-mock - v3.2.0

Published by stipsan almost 7 years ago

New Commands

SCAN command (#334 @DrMegavolt)

redis
  .scan(0, 'MATCH', 'foo*', 'COUNT', 1)
  .then(result => console.log(result))

LRANGE command (#335 @sseidametov)

redis
  .lrange('myKey', 0, 2)
  .then(result => console.log(result))
ioredis-mock - v3.1.3

Published by stipsan almost 7 years ago

  • Fixed: Errors in smembers and srem when no data is set (#332)
ioredis-mock - v3.1.2

Published by stipsan almost 7 years ago

  • Fixed: Fixed hexists edge cases (#331)
ioredis-mock - v3.1.1

Published by stipsan about 7 years ago

  • Fixed: Ignore codeclimate
ioredis-mock - v3.1.0

Published by stipsan about 7 years ago

New features

Add pipelining with method chaining (#312 @funnisimo)

Added a 'pipeline' method which allows chaining of methods like ioredis.

Updated discard and multi to work with the pipeline.

ioredis-mock - v3.0.2

Published by stipsan about 7 years ago

  • Fixed: Add back support for node v0.10.x like ioredis (#327)
ioredis-mock - v3.0.1

Published by stipsan about 7 years ago

  • Fixed: remove README and RunKit references to old import style
ioredis-mock - v3.0.0

Published by stipsan about 7 years ago

Breaking changes

Use module.exports to be in line with ioredis (#311 @rexxars)

ioredis uses commonjs exports, and now ioredis-mock does as well.

require('ioredis-mock').default no longer works, use require('ioredis-mock') instead.

Bug fixes

Error thrown in sismember() if key does not exist (#318 @theogravity)

ioredis-mock - v2.4.1

Published by stipsan about 7 years ago

  • Fixed: Allow ioredis 3 as peer dependency (#317 @aruberto)