@azteam/redis-async 1.0.48 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/Provider.js +1 -2
- package/src/RedisAsync.js +2 -9
- package/src/index.js +1 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azteam/redis-async",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.51",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/toda93/redis-async#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@azteam/util": "1.0.
|
|
27
|
+
"@azteam/util": "1.0.9",
|
|
28
28
|
"redis": "4.0.6"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/Provider.js
CHANGED
|
@@ -6,7 +6,7 @@ class Provider {
|
|
|
6
6
|
this.configs = configs;
|
|
7
7
|
if (isSingle) {
|
|
8
8
|
this.configs = {
|
|
9
|
-
single: configs
|
|
9
|
+
single: configs,
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -17,7 +17,6 @@ class Provider {
|
|
|
17
17
|
}
|
|
18
18
|
return this.connections[name];
|
|
19
19
|
}
|
|
20
|
-
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export default Provider;
|
package/src/RedisAsync.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {createClient} from 'redis';
|
|
2
2
|
import {timeout} from '@azteam/util';
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
class RedisAsync {
|
|
6
5
|
constructor(config) {
|
|
7
6
|
this.connected = false;
|
|
@@ -41,7 +40,7 @@ class RedisAsync {
|
|
|
41
40
|
this.connected = false;
|
|
42
41
|
this._alert('connect', 'Redis disconnected');
|
|
43
42
|
this.client.quit();
|
|
44
|
-
}
|
|
43
|
+
},
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
this.client.connect();
|
|
@@ -61,11 +60,9 @@ class RedisAsync {
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
async get(key, defaultValue = null) {
|
|
64
|
-
|
|
65
63
|
const prefixKey = this.parsePrefix(key);
|
|
66
64
|
|
|
67
65
|
if (this.connected) {
|
|
68
|
-
|
|
69
66
|
console.log(`Redis GET ${prefixKey}`);
|
|
70
67
|
|
|
71
68
|
const data = await this.client.get(prefixKey);
|
|
@@ -80,7 +77,6 @@ class RedisAsync {
|
|
|
80
77
|
return defaultValue;
|
|
81
78
|
}
|
|
82
79
|
|
|
83
|
-
|
|
84
80
|
async ttl(key) {
|
|
85
81
|
const prefixKey = this.parsePrefix(key);
|
|
86
82
|
|
|
@@ -107,7 +103,6 @@ class RedisAsync {
|
|
|
107
103
|
return this.set(key, data, timeSecond, count + 1);
|
|
108
104
|
}
|
|
109
105
|
return false;
|
|
110
|
-
|
|
111
106
|
}
|
|
112
107
|
}
|
|
113
108
|
|
|
@@ -127,14 +122,13 @@ class RedisAsync {
|
|
|
127
122
|
} else {
|
|
128
123
|
const regexKey = '*' + prefixKey + '*';
|
|
129
124
|
|
|
130
|
-
const keys = await this.client.keys(regexKey)
|
|
125
|
+
const keys = await this.client.keys(regexKey);
|
|
131
126
|
|
|
132
127
|
if (keys.length > 0) {
|
|
133
128
|
console.log(`Redis REMOVE keys`, keys);
|
|
134
129
|
return await this.client.del(keys);
|
|
135
130
|
}
|
|
136
131
|
}
|
|
137
|
-
|
|
138
132
|
} else {
|
|
139
133
|
this.connect();
|
|
140
134
|
if (count < 5) {
|
|
@@ -144,7 +138,6 @@ class RedisAsync {
|
|
|
144
138
|
}
|
|
145
139
|
}
|
|
146
140
|
|
|
147
|
-
|
|
148
141
|
setAlertCallback(callback) {
|
|
149
142
|
this.alertCallback = callback;
|
|
150
143
|
}
|