From d2cfe2e36678075aa84a9c8a9132349398c6a48a Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 11 Apr 2023 14:46:52 +0800 Subject: [PATCH] fix(nocodb): handle NONE in appendToList --- packages/nocodb/src/lib/cache/RedisCacheMgr.ts | 6 +++++- packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/cache/RedisCacheMgr.ts b/packages/nocodb/src/lib/cache/RedisCacheMgr.ts index 81c12be319..1f4b0170e6 100644 --- a/packages/nocodb/src/lib/cache/RedisCacheMgr.ts +++ b/packages/nocodb/src/lib/cache/RedisCacheMgr.ts @@ -247,7 +247,11 @@ export default class RedisCacheMgr extends CacheMgr { ? `${this.prefix}:${scope}:list` : `${this.prefix}:${scope}:${subListKeys.join(':')}:list`; log(`RedisCacheMgr::appendToList: append key ${key} to ${listKey}`); - const list = (await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; + let list = (await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; + if (list.length === 1 && list[0] === 'NONE') { + list = []; + await this.del(listKey); + } list.push(key); return this.set(listKey, list); } diff --git a/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts b/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts index a2fe30c10b..0d83ba5b1b 100644 --- a/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts +++ b/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts @@ -247,7 +247,11 @@ export default class RedisMockCacheMgr extends CacheMgr { ? `${this.prefix}:${scope}:list` : `${this.prefix}:${scope}:${subListKeys.join(':')}:list`; log(`RedisMockCacheMgr::appendToList: append key ${key} to ${listKey}`); - const list = (await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; + let list = (await this.get(listKey, CacheGetType.TYPE_ARRAY)) || []; + if (list.length === 1 && list[0] === 'NONE') { + list = []; + await this.del(listKey); + } list.push(key); return this.set(listKey, list); }