MCPcopy Create free account
hub / github.com/evolution-foundation/evolution-api / getConnection

Method getConnection

src/cache/rediscache.client.ts:15–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13 }
14
15 getConnection(): RedisClientType {
16 if (this.connected) {
17 return this.client;
18 } else {
19 this.client = createClient({
20 url: this.conf.URI,
21 });
22
23 this.client.on('connect', () => {
24 this.logger.verbose('redis connecting');
25 });
26
27 this.client.on('ready', () => {
28 this.logger.verbose('redis ready');
29 this.connected = true;
30 });
31
32 this.client.on('error', () => {
33 this.logger.error('redis disconnected');
34 this.connected = false;
35 });
36
37 this.client.on('end', () => {
38 this.logger.verbose('redis connection ended');
39 this.connected = false;
40 });
41
42 try {
43 this.client.connect();
44 this.connected = true;
45 } catch (e) {
46 this.connected = false;
47 this.logger.error('redis connect exception caught: ' + e);
48 return null;
49 }
50
51 return this.client;
52 }
53 }
54}
55
56export const redisClient = new Redis();

Callers 1

constructorMethod · 0.45

Calls 3

verboseMethod · 0.80
errorMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected