shuttlepro-shared 1.2.37 → 1.2.38
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.
|
@@ -123,6 +123,7 @@ const deleteUserRole = async (id) => {
|
|
|
123
123
|
|
|
124
124
|
const findUserWorkspaces = async (userId) => {
|
|
125
125
|
const cacheKey = `${CACHE_KEY_USER_WORKSPACE_PREFIX}${userId}`;
|
|
126
|
+
console.log(cacheKey, "cacheKey");
|
|
126
127
|
let userRoleWithWorkspaces = await getDataFromRedisSet(cacheKey);
|
|
127
128
|
console.log(userRoleWithWorkspaces, "from cache");
|
|
128
129
|
if (!userRoleWithWorkspaces.length) {
|
|
@@ -142,9 +143,16 @@ const findUserWorkspaces = async (userId) => {
|
|
|
142
143
|
})
|
|
143
144
|
.lean()
|
|
144
145
|
.exec();
|
|
145
|
-
console.log(userRoleWithWorkspaces, "through db");
|
|
146
146
|
if (userRoleWithWorkspaces) {
|
|
147
|
-
await addArrayToRedisSet(
|
|
147
|
+
await addArrayToRedisSet(
|
|
148
|
+
cacheKey,
|
|
149
|
+
userRoleWithWorkspaces?.map((x) => {
|
|
150
|
+
return {
|
|
151
|
+
...x,
|
|
152
|
+
_id: x?._id?.toString(),
|
|
153
|
+
};
|
|
154
|
+
})
|
|
155
|
+
);
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
return userRoleWithWorkspaces;
|
package/config/redis.js
CHANGED
|
@@ -110,9 +110,13 @@ const addArrayToRedisSet = async (key, value) => {
|
|
|
110
110
|
|
|
111
111
|
const arr = Array.isArray(value) ? value : [value];
|
|
112
112
|
|
|
113
|
+
console.log(arr, "arr");
|
|
114
|
+
|
|
113
115
|
// Convert each item to string (usually JSON)
|
|
114
116
|
const stringifiedArr = arr.map((item) => JSON.stringify(item));
|
|
115
117
|
|
|
118
|
+
console.log(stringifiedArr, "stringifiedArr");
|
|
119
|
+
|
|
116
120
|
await client.sAdd(key, ...stringifiedArr);
|
|
117
121
|
return true;
|
|
118
122
|
} catch (err) {
|