shuttlepro-shared 1.1.100 → 1.2.1
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/config/redis.js +5 -3
- package/package.json +1 -1
package/config/redis.js
CHANGED
|
@@ -53,12 +53,13 @@ const publishToChannel = async (channel, message) => {
|
|
|
53
53
|
* @param {string} channel - The Redis Pub/Sub channel
|
|
54
54
|
* @param {function} callback - Callback function to handle messages
|
|
55
55
|
*/
|
|
56
|
-
const subscribeToChannel = async (channel, callback) => {
|
|
56
|
+
const subscribeToChannel = async (channel, callback, expiry = false) => {
|
|
57
57
|
try {
|
|
58
58
|
await connectRedis();
|
|
59
59
|
await subscriber.subscribe(channel, (message) => {
|
|
60
60
|
console.log(`📥 Message received on channel: ${channel}`);
|
|
61
|
-
callback(
|
|
61
|
+
if (expiry) callback(message);
|
|
62
|
+
else callback(JSON.parse(message));
|
|
62
63
|
});
|
|
63
64
|
} catch (err) {
|
|
64
65
|
console.error("❌ Error subscribing to channel:", err);
|
|
@@ -115,8 +116,9 @@ const removeDataFromRedisSet = async (key, value) => {
|
|
|
115
116
|
const isMemberOfRedisSet = async (key, value) => {
|
|
116
117
|
try {
|
|
117
118
|
await connectRedis();
|
|
118
|
-
await client.sIsMember(key, value);
|
|
119
|
+
return await client.sIsMember(key, value);
|
|
119
120
|
} catch (err) {
|
|
121
|
+
console.log(err, "err");
|
|
120
122
|
return false;
|
|
121
123
|
}
|
|
122
124
|
};
|