ioredis-mock

Emulates ioredis by performing all operations in-memory.

MIT License

Downloads
2.5M
Stars
326
Committers
91

Bot releases are hidden (Show)

ioredis-mock - v6.5.0

Published by stipsan over 2 years ago

6.5.0 (2022-01-31)

Features

ioredis-mock - v6.4.0

Published by stipsan over 2 years ago

6.4.0 (2022-01-30)

Bug Fixes

  • hstrlen throws error if wrong number of arguments (a028d32)
  • rpush error message synced with redis (c58eda0)

Features

ioredis-mock - v6.3.0

Published by stipsan over 2 years ago

6.3.0 (2022-01-29)

Features

Added

  • appendBuffer
  • bgrewriteaofBuffer
  • bgsaveBuffer
  • brpoplpushBuffer
  • dbsizeBuffer
  • decrBuffer
  • decrbyBuffer
  • delBuffer
  • discardBuffer
  • echoBuffer
  • existsBuffer
  • expireBuffer
  • expireatBuffer
  • flushallBuffer
  • flushdbBuffer
  • getbitBuffer
  • getrangeBuffer
  • hdelBuffer
  • hexistsBuffer
  • hmsetBuffer
  • hsetBuffer
  • incrBuffer
  • incrbyBuffer
  • incrbyfloatBuffer
  • infoBuffer
  • keysBuffer
  • lastsaveBuffer
  • msetBuffer
  • pingBuffer
  • quitBuffer
  • replconf
  • replconfBuffer
  • saddBuffer
  • saveBuffer
  • setBuffer

Improved

  • get is updated to convert buffers to string, like native redis + ioredis,
ioredis-mock - v6.2.0

Published by stipsan over 2 years ago

6.2.0 (2022-01-28)

Features

Constructor shorthands now supported:

  • new Redis(6379, 'localhost', { keyPrefix: 'shared:' })
  • new Redis('//localhost:6379', { keyPrefix: 'shared:' })
  • new Redis('redis://localhost:6379', { keyPrefix: 'private:' })
  • new Redis(6379, { keyPrefix: 'shared:' })
  • new Redis(6379)
  • new Redis('redis://localhost:6379/')
ioredis-mock - v6.1.2

Published by stipsan over 2 years ago

6.1.2 (2022-01-28)

Bug Fixes

  • improve bgrewriteaof, bgsave, decrby, rpoplpush & time (#1126) (4907dab)

bgrewriteaof

  • returns 'Background append only file rewriting started' instead of 'OK'

bgsave

  • returns 'Background saving started' instead of 'OK'

decrby

  • throws "ERR wrong number of arguments for 'decrby' command" if the decrement argument is missing

rpoplpush

  • throws 'WRONGTYPE Operation against a key holding the wrong kind of value' if the source argument is invalid
  • returns null if the destination is invalid

time

  • returns strings instead of numbers
ioredis-mock - v6.1.1

Published by stipsan over 2 years ago

6.1.1 (2022-01-28)

Bug Fixes

  • flushall should mutate data, not fork it (#1125) (45fc377)
ioredis-mock - v6.1.0

Published by stipsan over 2 years ago

6.1.0 (2022-01-28)

Features

  • add browser build & deprecate jest build (#1123) (b0e02e1)

Browser usage (Experimental)

There's a browser build available. You can import it directly (import Redis from 'ioredis-mock/browser.js'), or use it on unpkg.com:

import Redis from 'https://unpkg.com/ioredis-mock';

const redis = new Redis();
redis.set('foo', 'bar');
console.log(await redis.get('foo'));

ioredis-mock/jest.js is deprecated

ioredis-mock is no longer doing a import { Command } from 'ioredis' internally, it's now doing a direct import import Command from 'ioredis/built/command' and thus the jest.js workaround is no longer needed:

-jest.mock('ioredis', () => require('ioredis-mock/jest'))
+jest.mock('ioredis', () => require('ioredis-mock'))
ioredis-mock -

Published by stipsan over 2 years ago

This is a republish of v5.8.4 as v5.9.0 is a breaking release that's republished as v6.0.0

ioredis-mock - v6.0.0

Published by stipsan over 2 years ago

6.0.0 (2022-01-25)

BREAKING CHANGE

Before v6, each instance of ioredis-mock lived in isolation:

const Redis = require('ioredis-mock');
const redis1 = new Redis();
const redis2 = new Redis();
await redis1.set('foo', 'bar');
console.log(await redis1.get('foo'), await redis2.get('foo')); // 'bar', null

In v6 the internals were rewritten to behave more like real life redis, if the host and port is the same, the context is now shared:

const Redis = require('ioredis-mock');
const redis1 = new Redis();
const redis2 = new Redis();
const redis3 = new Redis({ port: 6380 }); // 6379 is the default port
await redis1.set('foo', 'bar');
console.log(
  await redis1.get('foo'), // 'bar'
  await redis2.get('foo'), // 'bar'
  await redis3.get('foo') // null
);

And since ioredis-mock now persist data between instances, you'll likely need to run flushall between testing suites:

const Redis = require('ioredis-mock');
afterEach((done) => {
  new Redis().flushall().then(() => done());
});

createConnectedClient is deprecated

Replace it with .duplicate() or use another new Redis instance.

ioredis-mock - v5.9.0

Published by stipsan almost 3 years ago

5.9.0 (2022-01-22)

This is a breaking release by accident

See v6.0.0 instead, which includes upgrade notes. Or stay on v5.9.1 or v5.8.4 until you're ready to migrate.

Features

  • pubsub: Add shared context among Redis instances (#1110) (3da06de), closes #773
ioredis-mock - v5.8.4

Published by stipsan almost 3 years ago

5.8.4 (2022-01-21)

Bug Fixes

ioredis-mock - v5.8.3

Published by stipsan almost 3 years ago

5.8.3 (2022-01-21)

Bug Fixes

  • Add duplicate function to support instance duplication for TypeScript mocks (#1109) (f84897d)
ioredis-mock - v5.8.2

Published by stipsan almost 3 years ago

5.8.2 (2022-01-21)

Bug Fixes

ioredis-mock - v5.8.1

Published by stipsan almost 3 years ago

5.8.1 (2021-11-30)

Bug Fixes

  • deps: update dependency fengari-interop to v0.1.3 (04fcbca)
ioredis-mock - v5.8.0

Published by stipsan almost 3 years ago

5.8.0 (2021-11-15)

Features

ioredis-mock - v5.7.0

Published by stipsan almost 3 years ago

5.7.0 (2021-11-04)

Features

Reverts

ioredis-mock - v5.6.1

Published by stipsan almost 3 years ago

5.6.1 (2021-11-03)

Bug Fixes

ioredis-mock - v5.6.0

Published by stipsan over 3 years ago

5.6.0 (2021-05-29)

Features

ioredis-mock - v5.5.7

Published by stipsan over 3 years ago

5.5.7 (2021-05-26)

Bug Fixes

ioredis-mock - v5.5.6

Published by stipsan over 3 years ago

5.5.6 (2021-05-13)

Bug Fixes

  • commands: implement correct redis pattern matching algorithm instead of using minimatch (#1076) (68ccbd2)
Package Rankings
Top 1.31% on Npmjs.org
Badges
Extracted from project README
npm npm version Redis Compatibility: 66% semantic-release