@@ -192,11 +192,6 @@ async function createGroup(currentUser, data) {
192
192
await helper . postBusEvent ( config . KAFKA_GROUP_CREATE_TOPIC , group )
193
193
await tx . commit ( )
194
194
195
- // set the cache
196
- const cache = await helper . getCacheInstance ( )
197
- cache . set ( group . id , group )
198
- cache . set ( `${ group . id } -members` , [ ] )
199
-
200
195
return group
201
196
} catch ( error ) {
202
197
logger . error ( error )
@@ -275,9 +270,9 @@ async function updateGroup(currentUser, groupId, data) {
275
270
await helper . postBusEvent ( config . KAFKA_GROUP_UPDATE_TOPIC , updatedGroup )
276
271
await tx . commit ( )
277
272
278
- // update the cache
273
+ // update the cache only if the group has the `oldId`
279
274
const cache = await helper . getCacheInstance ( )
280
- cache . set ( group . id , updatedGroup )
275
+ if ( updateGroup . oldId && updateGroup . oldId . length > 0 ) cache . set ( group . id , updatedGroup )
281
276
282
277
return updatedGroup
283
278
} catch ( error ) {
@@ -425,7 +420,7 @@ async function getGroup(currentUser, groupId, criteria) {
425
420
)
426
421
}
427
422
}
428
-
423
+
429
424
let session
430
425
const getSession = ( ) => {
431
426
if ( ! session ) {
@@ -459,7 +454,9 @@ async function getGroup(currentUser, groupId, criteria) {
459
454
}
460
455
} else {
461
456
groupToReturn = await helper . ensureExists ( getSession ( ) , 'Group' , groupId , isAdmin )
462
- cache . set ( groupId , groupToReturn )
457
+
458
+ // set the group in cache only if it is having the `oldId`
459
+ if ( groupToReturn . oldId && groupToReturn . oldId . length > 0 ) cache . set ( groupId , groupToReturn )
463
460
464
461
if ( ! isAdmin ) delete groupToReturn . status
465
462
@@ -504,7 +501,9 @@ async function getGroup(currentUser, groupId, criteria) {
504
501
} )
505
502
506
503
groupToReturn . flattenGroupIdTree = flattenGroupIdTree
507
- cache . set ( groupId , groupToReturn )
504
+
505
+ // set the group in cache only if it is having the `oldId`
506
+ if ( groupToReturn . oldId && groupToReturn . oldId . length > 0 ) cache . set ( groupId , groupToReturn )
508
507
}
509
508
} else if ( criteria . includeParentGroup && ! groupToReturn . parentGroups ) {
510
509
// find parent groups
0 commit comments