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. 10
      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> { protected async disableSharedBaseLink(_req, args: any): Promise<any> {
try { 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( await this.xcMeta.metaDelete(
this.getProjectId(args), this.getProjectId(args),
this.getDbAlias(args), this.getDbAlias(args),

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

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

Loading…
Cancel
Save