From 5b55db280c2a6378ade6f392c60ab0a2d7cc2b69 Mon Sep 17 00:00:00 2001 From: mertmit Date: Fri, 19 Jan 2024 14:19:27 +0000 Subject: [PATCH] fix: base cache --- packages/nocodb/src/models/Base.ts | 44 ++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/packages/nocodb/src/models/Base.ts b/packages/nocodb/src/models/Base.ts index 8d704fea13..b408f30dc9 100644 --- a/packages/nocodb/src/models/Base.ts +++ b/packages/nocodb/src/models/Base.ts @@ -175,7 +175,10 @@ export default class Base implements BaseType { await NocoCache.set(`${CacheScope.PROJECT}:${baseId}`, baseData); } if (baseData?.uuid) { - await NocoCache.set(`${CacheScope.PROJECT}:${baseData.uuid}`, baseId); + await NocoCache.set( + `${CacheScope.PROJECT_ALIAS}:${baseData.uuid}`, + baseId, + ); } } else { if (baseData?.deleted) { @@ -200,16 +203,15 @@ export default class Base implements BaseType { const key = `${CacheScope.PROJECT}:${baseId}`; const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); if (o) { - // delete : - await NocoCache.del(`${CacheScope.PROJECT}:${baseId}`); - await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:${baseId}`); // delete : - await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:${o.title}`); // delete <scope>:<uuid> - await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:${o.uuid}`); // delete <scope>:ref:<titleOfId> - await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:ref:${o.title}`); - await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:ref:${o.id}`); + await NocoCache.del([ + `${CacheScope.PROJECT_ALIAS}:${o.title}`, + `${CacheScope.PROJECT_ALIAS}:${o.uuid}`, + `${CacheScope.PROJECT_ALIAS}:ref:${o.title}`, + `${CacheScope.PROJECT_ALIAS}:ref:${o.id}`, + ]); } await NocoCache.del(CacheScope.INSTANCE_META); @@ -258,16 +260,22 @@ export default class Base implements BaseType { // update data // new uuid is generated if (o.uuid && updateObj.uuid && o.uuid !== updateObj.uuid) { - await NocoCache.del(`${CacheScope.PROJECT}:${o.uuid}`); - await NocoCache.set(`${CacheScope.PROJECT}:${updateObj.uuid}`, baseId); + await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:${o.uuid}`); + await NocoCache.set( + `${CacheScope.PROJECT_ALIAS}:${updateObj.uuid}`, + baseId, + ); } // disable shared base if (o.uuid && updateObj.uuid === null) { - await NocoCache.del(`${CacheScope.PROJECT}:${o.uuid}`); + await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:${o.uuid}`); } if (o.title && updateObj.title && o.title !== updateObj.title) { - await NocoCache.del(`${CacheScope.PROJECT}:${o.title}`); - await NocoCache.set(`${CacheScope.PROJECT}:${updateObj.title}`, baseId); + await NocoCache.del(`${CacheScope.PROJECT_ALIAS}:${o.title}`); + await NocoCache.set( + `${CacheScope.PROJECT_ALIAS}:${updateObj.title}`, + baseId, + ); } o = { ...o, ...updateObj }; @@ -311,12 +319,14 @@ export default class Base implements BaseType { if (base) { // delete <scope>:<uuid> - await NocoCache.del(`${CacheScope.PROJECT}:${base.uuid}`); // delete <scope>:<title> - await NocoCache.del(`${CacheScope.PROJECT}:${base.title}`); // delete <scope>:ref:<titleOfId> - await NocoCache.del(`${CacheScope.PROJECT}:ref:${base.title}`); - await NocoCache.del(`${CacheScope.PROJECT}:ref:${base.id}`); + await NocoCache.del([ + `${CacheScope.PROJECT_ALIAS}:${base.uuid}`, + `${CacheScope.PROJECT_ALIAS}:${base.title}`, + `${CacheScope.PROJECT_ALIAS}:ref:${base.title}`, + `${CacheScope.PROJECT_ALIAS}:ref:${base.id}`, + ]); } await NocoCache.deepDel(