Skip to content

Commit 1931bb4

Browse files
authored
Merge pull request #86 from blimmer/feature/replace-then-redis
Replace then-redis with ioredis
2 parents b299ad5 + efc86ce commit 1931bb4

File tree

6 files changed

+765
-538
lines changed

6 files changed

+765
-538
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
language: node_js
22
node_js:
3-
- 4
4-
- 6
3+
- '4'
4+
- '6'
5+
- '8'
6+
- '10'
57
sudo: false
68
cache:
79
yarn: true

lib/redis.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = CoreObject.extend({
66
init: function(options, lib) {
77
this._super();
88
var redisOptions = {};
9-
var redisLib = lib;
9+
var RedisLib = lib;
1010

1111
if (options.url) {
1212
redisOptions = this._stripUsernameFromConfigUrl(options.url);
@@ -21,15 +21,15 @@ module.exports = CoreObject.extend({
2121
}
2222

2323
if (options.database) {
24-
redisOptions.database = options.database;
24+
redisOptions.db = options.database;
2525
}
2626
}
2727

28-
if (!redisLib) {
29-
redisLib = require('then-redis');
28+
if (!RedisLib) {
29+
RedisLib = require('ioredis');
3030
}
3131

32-
this._client = redisLib.createClient(redisOptions);
32+
this._client = new RedisLib(redisOptions);
3333

3434
this._maxRecentUploads = options.maxRecentUploads;
3535
this._allowOverwrite = options.allowOverwrite;
@@ -204,13 +204,16 @@ module.exports = CoreObject.extend({
204204
if (!revisions) {
205205
return;
206206
}
207+
var promises = [];
207208
revisions.forEach(function(revision) {
208209
if (revision !== current) {
209-
client.del(keyPrefix + ":" + revision);
210-
client.del(keyPrefix + ":revision-data:" + revision);
211-
client.zrem(listKey, revision);
210+
promises.push(client.del(keyPrefix + ":" + revision));
211+
promises.push(client.del(keyPrefix + ":revision-data:" + revision));
212+
promises.push(client.zrem(listKey, revision));
212213
}
213214
});
215+
216+
return RSVP.all(promises);
214217
});
215218
},
216219

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
"eslint": "^3.18.0",
2424
"github": "^6.1.0",
2525
"glob": "^7.1.1",
26+
"ioredis-mock": "^3.14.0",
2627
"mocha": "^3.2.0",
27-
"multiline": "^1.0.2"
28+
"multiline": "^1.0.2",
29+
"sinon": "^6.1.5"
2830
},
2931
"keywords": [
3032
"ember-addon",
@@ -34,9 +36,9 @@
3436
"chalk": "^1.1.3",
3537
"core-object": "^2.0.6",
3638
"ember-cli-deploy-plugin": "^0.2.9",
39+
"ioredis": "^3.2.2",
3740
"redis": "^2.6.3",
38-
"rsvp": "^3.0.18",
39-
"then-redis": "^2.0.1"
41+
"rsvp": "^3.0.18"
4042
},
4143
"ember-addon": {
4244
"configPath": "tests/dummy/config"

0 commit comments

Comments
 (0)