Browse Source

fix: use props arg for MODEL_ROLE_VISIBILITY case

pull/7464/head
mertmit 10 months ago
parent
commit
127e036985
  1. 9
      packages/nocodb/src/cache/RedisCacheMgr.ts
  2. 9
      packages/nocodb/src/cache/RedisMockCacheMgr.ts
  3. 7
      packages/nocodb/src/models/ModelRoleVisibility.ts

9
packages/nocodb/src/cache/RedisCacheMgr.ts vendored

@ -1,7 +1,7 @@
import debug from 'debug';
import Redis from 'ioredis';
import CacheMgr from './CacheMgr';
import { CacheDelDirection, CacheGetType, CacheScope } from '~/utils/globals';
import { CacheDelDirection, CacheGetType } from '~/utils/globals';
const log = debug('nc:cache');
@ -207,13 +207,6 @@ export default class RedisCacheMgr extends CacheMgr {
const propValues = props.map((p) => o[p]);
// 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
log(`RedisCacheMgr::setList: setting key ${getKey}`);

9
packages/nocodb/src/cache/RedisMockCacheMgr.ts vendored

@ -2,7 +2,7 @@ import debug from 'debug';
import Redis from 'ioredis-mock';
import CacheMgr from './CacheMgr';
import type IORedis from 'ioredis';
import { CacheDelDirection, CacheGetType, CacheScope } from '~/utils/globals';
import { CacheDelDirection, CacheGetType } from '~/utils/globals';
const log = debug('nc:cache');
export default class RedisMockCacheMgr extends CacheMgr {
@ -205,13 +205,6 @@ export default class RedisMockCacheMgr extends CacheMgr {
const propValues = props.map((p) => o[p]);
// 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
log(`RedisMockCacheMgr::setList: setting key ${getKey}`);

7
packages/nocodb/src/models/ModelRoleVisibility.ts

@ -36,7 +36,12 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType {
null,
MetaTable.MODEL_ROLE_VISIBILITY,
);
await NocoCache.setList(CacheScope.MODEL_ROLE_VISIBILITY, [baseId], data);
await NocoCache.setList(
CacheScope.MODEL_ROLE_VISIBILITY,
[baseId],
data,
['fk_view_id', 'role'],
);
}
return data?.map((baseData) => new ModelRoleVisibility(baseData));
}

Loading…
Cancel
Save