Browse Source

refactor: update cache only after metadb change

pull/8281/head
Pranav C 6 months ago
parent
commit
4bda004613
  1. 19
      packages/nocodb/src/models/GalleryViewColumn.ts
  2. 23
      packages/nocodb/src/models/KanbanViewColumn.ts
  3. 18
      packages/nocodb/src/models/MapViewColumn.ts

19
packages/nocodb/src/models/GalleryViewColumn.ts

@ -128,23 +128,26 @@ export default class GalleryViewColumn {
ncMeta = Noco.ncMeta,
) {
const updateObj = extractProps(body, ['order', 'show']);
// set meta
const res = await ncMeta.metaUpdate(
null,
null,
MetaTable.GALLERY_VIEW_COLUMNS,
updateObj,
columnId,
);
// get existing cache
const key = `${CacheScope.GALLERY_VIEW_COLUMN}:${columnId}`;
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
if (o) {
// update data
o = { ...o, ...updateObj };
// set cache
await NocoCache.set(key, o);
}
// set meta
const res = await ncMeta.metaUpdate(
null,
null,
MetaTable.GALLERY_VIEW_COLUMNS,
updateObj,
columnId,
);
// on view column update, delete any optimised single query cache
{

23
packages/nocodb/src/models/KanbanViewColumn.ts

@ -119,10 +119,17 @@ export default class KanbanViewColumn implements KanbanColumnType {
body: Partial<KanbanViewColumn>,
ncMeta = Noco.ncMeta,
) {
const updateObj = extractProps(body, [
'order',
'show'
]);
const updateObj = extractProps(body, ['order', 'show']);
// set meta
const res = await ncMeta.metaUpdate(
null,
null,
MetaTable.KANBAN_VIEW_COLUMNS,
updateObj,
columnId,
);
// get existing cache
const key = `${CacheScope.KANBAN_VIEW_COLUMN}:${columnId}`;
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
@ -132,14 +139,6 @@ export default class KanbanViewColumn implements KanbanColumnType {
// set cache
await NocoCache.set(key, o);
}
// set meta
const res = await ncMeta.metaUpdate(
null,
null,
MetaTable.KANBAN_VIEW_COLUMNS,
updateObj,
columnId,
);
// on view column update, delete any optimised single query cache
{

18
packages/nocodb/src/models/MapViewColumn.ts

@ -117,6 +117,16 @@ export default class MapViewColumn {
'group_by_order',
'group_by_sort',
]);
// set meta
const res = await ncMeta.metaUpdate(
null,
null,
MetaTable.MAP_VIEW_COLUMNS,
updateObj,
columnId,
);
// get existing cache
const key = `${CacheScope.MAP_VIEW_COLUMN}:${columnId}`;
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
@ -126,14 +136,6 @@ export default class MapViewColumn {
// set cache
await NocoCache.set(key, o);
}
// set meta
const res = await ncMeta.metaUpdate(
null,
null,
MetaTable.MAP_VIEW_COLUMNS,
updateObj,
columnId,
);
// on view column update, delete any optimised single query cache
{

Loading…
Cancel
Save