From 4c5ff7be29ae09b583de5fb3d377f0e6796fcb27 Mon Sep 17 00:00:00 2001 From: mertmit Date: Thu, 14 Dec 2023 10:55:17 +0300 Subject: [PATCH] fix: append before getList Signed-off-by: mertmit --- packages/nocodb/src/cache/RedisCacheMgr.ts | 9 +++++++-- packages/nocodb/src/cache/RedisMockCacheMgr.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/cache/RedisCacheMgr.ts b/packages/nocodb/src/cache/RedisCacheMgr.ts index dc03ed9a9c..9dacc2385a 100644 --- a/packages/nocodb/src/cache/RedisCacheMgr.ts +++ b/packages/nocodb/src/cache/RedisCacheMgr.ts @@ -276,8 +276,13 @@ export default class RedisCacheMgr extends CacheMgr { ? `${this.prefix}:${scope}:list` : `${this.prefix}:${scope}:${subListKeys.join(':')}:list`; log(`RedisCacheMgr::appendToList: append key ${key} to ${listKey}`); - let list = (await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; - if (list.length && list.includes('NONE')) { + let list = await this.get(listKey, CacheGetType.TYPE_ARRAY); + + if (!list || !list.length) { + return false; + } + + if (list.includes('NONE')) { list = []; await this.del(listKey); } diff --git a/packages/nocodb/src/cache/RedisMockCacheMgr.ts b/packages/nocodb/src/cache/RedisMockCacheMgr.ts index 1e28b36627..3381a4f7cb 100644 --- a/packages/nocodb/src/cache/RedisMockCacheMgr.ts +++ b/packages/nocodb/src/cache/RedisMockCacheMgr.ts @@ -276,8 +276,13 @@ export default class RedisMockCacheMgr extends CacheMgr { ? `${this.prefix}:${scope}:list` : `${this.prefix}:${scope}:${subListKeys.join(':')}:list`; log(`RedisMockCacheMgr::appendToList: append key ${key} to ${listKey}`); - let list = (await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; - if (list.length && list[0] === 'NONE') { + let list = await this.get(listKey, CacheGetType.TYPE_ARRAY); + + if (!list || !list.length) { + return false; + } + + if (list[0] === 'NONE') { list = []; await this.del(listKey); }