shuttlepro-shared 1.3.67 → 1.3.68

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.
Files changed (2) hide show
  1. package/config/redis.js +11 -2
  2. package/package.json +1 -1
package/config/redis.js CHANGED
@@ -41,6 +41,15 @@ const connectRedis = async () => {
41
41
  }
42
42
  };
43
43
 
44
+ // ✅ Ensure Redis is connected once during app startup
45
+ const connectRedisClient = async () => {
46
+ try {
47
+ if (!client.isOpen) await client.connect();
48
+ } catch (err) {
49
+ console.error("❌ Failed to connect to Redis:", err);
50
+ }
51
+ };
52
+
44
53
  // ✅ Publish Data to a Channel
45
54
  const publishToChannel = async (channel, message) => {
46
55
  try {
@@ -70,7 +79,7 @@ const setRedisData = async (
70
79
  expiryInSeconds = 3600
71
80
  ) => {
72
81
  try {
73
- await connectRedis();
82
+ await connectRedisClient();
74
83
  const stringifiedValue = JSON.stringify(value);
75
84
  let result;
76
85
 
@@ -94,7 +103,7 @@ const setRedisData = async (
94
103
  // ✅ Get Data from Redis (Supports String & Hash)
95
104
  const getRedisData = async (key, field = null) => {
96
105
  try {
97
- await connectRedis();
106
+ await connectRedisClient();
98
107
  const result = field
99
108
  ? await client.hGet(key, field)
100
109
  : await client.get(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shuttlepro-shared",
3
- "version": "1.3.67",
3
+ "version": "1.3.68",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {