1 | ioredis-mock
|
2 | ============
|
3 |
|
4 | [![AppVeyor branch](https://img.shields.io/appveyor/ci/stipsan/ioredis-mock/master.svg?label=windows)](https://ci.appveyor.com/project/stipsan/ioredis-mock)
|
5 | [![Travis branch](https://img.shields.io/travis/stipsan/ioredis-mock/master.svg?label=linux)](https://travis-ci.org/stipsan/ioredis-mock)
|
6 | [![CircleCI](https://img.shields.io/circleci/project/stipsan/ioredis-mock/master.svg?label=node+matrix)](https://circleci.com/gh/stipsan/ioredis-mock)
|
7 | [![Code Climate](https://codeclimate.com/github/stipsan/ioredis-mock/badges/gpa.svg)](https://codeclimate.com/github/stipsan/ioredis-mock)
|
8 | [![Coverage Status](https://coveralls.io/repos/github/stipsan/ioredis-mock/badge.svg)](https://coveralls.io/github/stipsan/ioredis-mock)
|
9 | [![npm package](https://img.shields.io/npm/dm/ioredis-mock.svg)](https://www.npmjs.com/package/ioredis-mock)
|
10 |
|
11 | [![NPM](https://nodei.co/npm/ioredis-mock.png?downloadRank=true)](https://www.npmjs.com/package/ioredis-mock)
|
12 | [![NPM](https://nodei.co/npm-dl/ioredis-mock.png?months=3&height=2)](https://nodei.co/npm/ioredis-mock/)
|
13 |
|
14 | This library emulates [ioredis](https://github.com/luin/ioredis) by performing all operations in-memory.
|
15 | The best way to do integration testing against redis and ioredis is on a real redis-server instance.
|
16 | However, there are cases where mocking the redis-server is a better option.
|
17 |
|
18 | Cases like:
|
19 |
|
20 | * Your workflow already use a local redis-server instance for the dev server.
|
21 | * You're on a platform [without an official redis release](https://github.com/MSOpenTech/redis), that's even worse than using an emulator.
|
22 | * You're running tests on a CI, setting it up is complicated. If you combine it with CI that also run selenium acceptance testing it's even more complicated, as two redis-server instances on the same CI build is hard.
|
23 | * The GitHub repo have bots that run the testing suite and is limited through npm package.json install scripts and can't fire up servers. (Having [Greenkeeper](https://greenkeeper.io/) notifying you when a new release of ioredis is out and wether your code breaks or not is awesome).
|
24 |
|
25 | ## Usage
|
26 |
|
27 | ```js
|
28 | var RedisMock = require('ioredis-mock').default;
|
29 | var redis = new RedisMock({
|
30 | data: {
|
31 | user_next: '3',
|
32 | emails: {
|
33 | 'clark@daily.planet': '1',
|
34 | 'bruce@wayne.enterprises': '2',
|
35 | },
|
36 | 'user:1': { id: '1', username: 'superman', email: 'clark@daily.planet' },
|
37 | 'user:2': { id: '2', username: 'batman', email: 'bruce@wayne.enterprises' },
|
38 | }
|
39 | });
|
40 | // Basically use it just like ioredis
|
41 | ```
|
42 |
|
43 | ## Try it out
|
44 | This project implements a Tonic example file so you can quickly [test ioredis-mock in your browser.](https://tonicdev.com/npm/ioredis-mock)
|
45 |
|
46 | ## [Mocked ioredis features](compat.md)
|
47 |
|
48 | ## Roadmap
|
49 | This project started off as just an utility in [another project](https://github.com/stipsan/epic) and just recently got open sourced to benefit the rest of the ioredis community. This means there's work to do before it's feature complete:
|
50 | - [x] Setup testing suite for the library itself.
|
51 | - [x] Refactor to bluebird promises like ioredis, support node style callback too.
|
52 | - [ ] Implement remaining basic features that read/write data.
|
53 | - [ ] Connection Events
|
54 | - [ ] Offline Queue
|
55 | - [ ] Pub/Sub
|
56 | - [ ] Error Handling
|
57 |
|
58 | ## I need a feature not listed here
|
59 |
|
60 | Just create an issue and tell us all about it or submit a PR with it! :-)
|