|
|
@ -185,6 +185,7 @@ export default class RedisMockCacheMgr extends CacheMgr { |
|
|
|
scope: string, |
|
|
|
scope: string, |
|
|
|
subListKeys: string[], |
|
|
|
subListKeys: string[], |
|
|
|
list: any[], |
|
|
|
list: any[], |
|
|
|
|
|
|
|
props: string[] = [], |
|
|
|
): Promise<boolean> { |
|
|
|
): Promise<boolean> { |
|
|
|
// remove null from arrays
|
|
|
|
// remove null from arrays
|
|
|
|
subListKeys = subListKeys.filter((k) => k); |
|
|
|
subListKeys = subListKeys.filter((k) => k); |
|
|
@ -203,11 +204,18 @@ export default class RedisMockCacheMgr extends CacheMgr { |
|
|
|
(await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; |
|
|
|
(await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; |
|
|
|
for (const o of list) { |
|
|
|
for (const o of list) { |
|
|
|
// construct key for Get
|
|
|
|
// construct key for Get
|
|
|
|
// e.g. nc:<orgs>:<scope>:<model_id_1>
|
|
|
|
|
|
|
|
let getKey = `${this.prefix}:${scope}:${o.id}`; |
|
|
|
let getKey = `${this.prefix}:${scope}:${o.id}`; |
|
|
|
// special case - MODEL_ROLE_VISIBILITY
|
|
|
|
if (props.length) { |
|
|
|
if (scope === CacheScope.MODEL_ROLE_VISIBILITY) { |
|
|
|
const propValues = props.map((p) => o[p]); |
|
|
|
getKey = `${this.prefix}:${scope}:${o.fk_view_id}:${o.role}`; |
|
|
|
// e.g. nc:<orgs>:<scope>:<prop_value_1>:<prop_value_2>
|
|
|
|
|
|
|
|
getKey = `${this.prefix}:${scope}:${propValues.join(':')}`; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// e.g. nc:<orgs>:<scope>:<model_id_1>
|
|
|
|
|
|
|
|
getKey = `${this.prefix}:${scope}:${o.id}`; |
|
|
|
|
|
|
|
// special case - MODEL_ROLE_VISIBILITY
|
|
|
|
|
|
|
|
if (scope === CacheScope.MODEL_ROLE_VISIBILITY) { |
|
|
|
|
|
|
|
getKey = `${this.prefix}:${scope}:${o.fk_view_id}:${o.role}`; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// set Get Key
|
|
|
|
// set Get Key
|
|
|
|
log(`RedisMockCacheMgr::setList: setting key ${getKey}`); |
|
|
|
log(`RedisMockCacheMgr::setList: setting key ${getKey}`); |
|
|
|