Skip to content

Commit 063504d

Browse files
authored
Merge pull request #24 from share/bump-redis-version
💥 Bump redis version to 5.0.0
2 parents 819b549 + abc1d92 commit 063504d

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ on:
1010

1111
jobs:
1212
test:
13-
name: Node.js ${{ matrix.node }}
13+
name: Node.js ${{ matrix.node }} - Redis ${{ matrix.redis }}
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
1717
node:
1818
- 16
1919
- 18
2020
- 20
21+
redis:
22+
- 4
23+
- 5
2124
services:
2225
redis:
2326
image: redis
@@ -31,6 +34,8 @@ jobs:
3134
node-version: ${{ matrix.node }}
3235
- name: Install
3336
run: npm install
37+
- name: Install correct redis version
38+
run: npm install redis@${{ matrix.redis }}
3439
- name: Lint
3540
run: npm run lint
3641
- name: Test

index.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,19 @@ RedisPubSub.prototype.close = function(callback) {
4242
};
4343

4444
RedisPubSub.prototype._close = function() {
45-
return this._closing = this._closing || this._connect().then(Promise.all([
46-
this.client.quit(),
47-
this.observer.quit()
48-
]));
45+
var pubsub = this;
46+
47+
if (!this._closing) {
48+
this._closing = this._connect()
49+
.then(function() {
50+
return Promise.all([
51+
close(pubsub.client),
52+
close(pubsub.observer)
53+
]);
54+
});
55+
}
56+
57+
return this._closing;
4958
};
5059

5160
RedisPubSub.prototype._subscribe = function(channel, callback) {
@@ -90,5 +99,15 @@ function connect(client) {
9099

91100
var PUBLISH_SCRIPT =
92101
'for i = 2, #ARGV do ' +
93-
'redis.call("publish", ARGV[i], ARGV[1]) ' +
102+
'redis.call("publish", ARGV[i], ARGV[1]) ' +
94103
'end';
104+
105+
function close(client) {
106+
if (client.close) {
107+
return client.close();
108+
}
109+
110+
// The quit is deprecated for node redis >= 5.0.0
111+
// This call should be removed after we stop supporting redis < 5.0.0
112+
return client.quit();
113+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "sharedb-redis-pubsub",
3-
"version": "5.0.1",
3+
"version": "5.1.0",
44
"description": "Redis pub/sub adapter adapter for ShareDB",
55
"main": "index.js",
66
"dependencies": {
7-
"redis": "^4.0.0",
7+
"redis": "^4.0.0 || ^5.0.0",
88
"sharedb": "^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
99
},
1010
"devDependencies": {

0 commit comments

Comments
 (0)