Browse Source

fix: use mget for getList

pull/7464/head
mertmit 10 months ago
parent
commit
57e081d17d
  1. 19
      packages/nocodb/src/cache/RedisCacheMgr.ts
  2. 19
      packages/nocodb/src/cache/RedisMockCacheMgr.ts

19
packages/nocodb/src/cache/RedisCacheMgr.ts vendored

@ -159,17 +159,28 @@ export default class RedisCacheMgr extends CacheMgr {
log(`RedisCacheMgr::getList: getting list with key ${key}`); log(`RedisCacheMgr::getList: getting list with key ${key}`);
const isNoneList = arr.length && arr.includes('NONE'); const isNoneList = arr.length && arr.includes('NONE');
if (isNoneList) { if (isNoneList || !arr.length) {
return Promise.resolve({ return Promise.resolve({
list: [], list: [],
isNoneList, isNoneList,
}); });
} }
log(`RedisCacheMgr::getList: getting list with keys ${arr}`);
const values = await this.client.mget(arr);
return { return {
list: await Promise.all( list: values.map((res) => {
arr.map(async (k) => await this.get(k, CacheGetType.TYPE_OBJECT)), try {
), const o = JSON.parse(res);
if (typeof o === 'object') {
return o;
}
} catch (e) {
return res;
}
return res;
}),
isNoneList, isNoneList,
}; };
} }

19
packages/nocodb/src/cache/RedisMockCacheMgr.ts vendored

@ -156,17 +156,28 @@ export default class RedisMockCacheMgr extends CacheMgr {
log(`RedisMockCacheMgr::getList: getting list with key ${key}`); log(`RedisMockCacheMgr::getList: getting list with key ${key}`);
const isNoneList = arr.length && arr[0] === 'NONE'; const isNoneList = arr.length && arr[0] === 'NONE';
if (isNoneList) { if (isNoneList || !arr.length) {
return Promise.resolve({ return Promise.resolve({
list: [], list: [],
isNoneList, isNoneList,
}); });
} }
log(`RedisCacheMgr::getList: getting list with keys ${arr}`);
const values = await this.client.mget(arr);
return { return {
list: await Promise.all( list: values.map((res) => {
arr.map(async (k) => await this.get(k, CacheGetType.TYPE_OBJECT)), try {
), const o = JSON.parse(res);
if (typeof o === 'object') {
return o;
}
} catch (e) {
return res;
}
return res;
}),
isNoneList, isNoneList,
}; };
} }

Loading…
Cancel
Save