Browse Source

feat: cache baseview data

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/765/head
Pranav C 3 years ago
parent
commit
0c2023cb93
  1. 10
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts
  2. 20
      packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts

10
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -3463,6 +3463,16 @@ export default class NcMetaMgr {
protected async disableSharedBaseLink(_req, args: any): Promise<any> {
try {
const sharedBase = await this.xcMeta.metaGet(
this.getProjectId(args),
this.getDbAlias(args),
'nc_shared_bases',
{
project_id: this.getProjectId(args)
}
);
if (!sharedBase) return;
XcCache.del(`nc_shared_bases||${sharedBase.shared_base_id}`);
await this.xcMeta.metaDelete(
this.getProjectId(args),
this.getDbAlias(args),

20
packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts

@ -592,14 +592,20 @@ export default class RestAuthCtrl {
new CustomStrategy(async (req: any, callback) => {
let user;
if (req.headers['xc-shared-base-id']) {
const sharedBase = await this.xcMeta
.knex('nc_shared_bases')
.where({
enabled: true,
shared_base_id: req.headers['xc-shared-base-id']
})
.first();
const cacheKey = `nc_shared_bases||${req.headers['xc-shared-base-id']}`;
let sharedBase = XcCache.get(cacheKey);
if (!sharedBase) {
sharedBase = await this.xcMeta
.knex('nc_shared_bases')
.where({
enabled: true,
shared_base_id: req.headers['xc-shared-base-id']
})
.first();
XcCache.set(cacheKey, sharedBase);
}
user = {
roles: sharedBase?.roles
};

Loading…
Cancel
Save