mielk-fn 1.2.1 → 1.2.2
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/dist/redis/redisClient.js +10 -5
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createClient } from 'redis';
|
|
2
|
-
const defaultHost = '127.0.0.1';
|
|
3
|
-
const defaultPort = '6379';
|
|
2
|
+
const defaultHost = '127.0.0.1'; //'127.0.0.1';
|
|
3
|
+
const defaultPort = '6179'; //'6379';
|
|
4
|
+
let redisConfig = { host: defaultHost, port: defaultPort };
|
|
4
5
|
let redisClient = null;
|
|
5
6
|
let connected = false;
|
|
6
7
|
const createRedisClient = (config) => {
|
|
7
|
-
const { host, port } = config
|
|
8
|
+
const { host, port } = config;
|
|
8
9
|
const client = createClient({
|
|
9
|
-
url: `redis://${host
|
|
10
|
+
url: `redis://${host}:${port}`,
|
|
10
11
|
});
|
|
11
12
|
client.on('error', (err) => console.error('Redis error:', err));
|
|
12
13
|
console.log('Redis URL:', `redis://${host}:${port}`);
|
|
@@ -14,7 +15,11 @@ const createRedisClient = (config) => {
|
|
|
14
15
|
};
|
|
15
16
|
export async function getRedisClient(config) {
|
|
16
17
|
if (redisClient === null) {
|
|
17
|
-
|
|
18
|
+
redisConfig = {
|
|
19
|
+
...redisConfig,
|
|
20
|
+
...config,
|
|
21
|
+
};
|
|
22
|
+
redisClient = createRedisClient(redisConfig);
|
|
18
23
|
}
|
|
19
24
|
if (!connected) {
|
|
20
25
|
await redisClient.connect();
|