From 60da4ab82f179d60d9fd466b4be0e72bcb46eb44 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 16 Apr 2024 07:14:21 +0000 Subject: [PATCH] refactor: use update method for modifying partial data in cache --- packages/nocodb/src/models/GalleryViewColumn.ts | 9 +-------- packages/nocodb/src/models/KanbanViewColumn.ts | 8 +------- packages/nocodb/src/models/MapViewColumn.ts | 8 +------- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/packages/nocodb/src/models/GalleryViewColumn.ts b/packages/nocodb/src/models/GalleryViewColumn.ts index 5a4a36fe4b..3ae4319811 100644 --- a/packages/nocodb/src/models/GalleryViewColumn.ts +++ b/packages/nocodb/src/models/GalleryViewColumn.ts @@ -140,14 +140,7 @@ export default class GalleryViewColumn { // 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); - } + await NocoCache.update(key, updateObj); // on view column update, delete any optimised single query cache { diff --git a/packages/nocodb/src/models/KanbanViewColumn.ts b/packages/nocodb/src/models/KanbanViewColumn.ts index 468bf1cf74..495e1df8f0 100644 --- a/packages/nocodb/src/models/KanbanViewColumn.ts +++ b/packages/nocodb/src/models/KanbanViewColumn.ts @@ -132,13 +132,7 @@ export default class KanbanViewColumn implements KanbanColumnType { // get existing cache const key = `${CacheScope.KANBAN_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); - } + await NocoCache.update(key, updateObj); // on view column update, delete any optimised single query cache { diff --git a/packages/nocodb/src/models/MapViewColumn.ts b/packages/nocodb/src/models/MapViewColumn.ts index 04631643c3..7e82e4510c 100644 --- a/packages/nocodb/src/models/MapViewColumn.ts +++ b/packages/nocodb/src/models/MapViewColumn.ts @@ -129,13 +129,7 @@ export default class MapViewColumn { // get existing cache const key = `${CacheScope.MAP_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); - } + await NocoCache.update(key, updateObj); // on view column update, delete any optimised single query cache {