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}`);
const isNoneList = arr.length && arr.includes('NONE');
if (isNoneList) {
if (isNoneList || !arr.length) {
return Promise.resolve({
list: [],
isNoneList,
});
}
log(`RedisCacheMgr::getList: getting list with keys ${arr}`);
const values = await this.client.mget(arr);
return {
list: await Promise.all(
arr.map(async (k) => await this.get(k, CacheGetType.TYPE_OBJECT)),
),
list: values.map((res) => {
try {
const o = JSON.parse(res);
if (typeof o === 'object') {
return o;
}
} catch (e) {
return res;
}
return res;
}),
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}`);
const isNoneList = arr.length && arr[0] === 'NONE';
if (isNoneList) {
if (isNoneList || !arr.length) {
return Promise.resolve({
list: [],
isNoneList,
});
}
log(`RedisCacheMgr::getList: getting list with keys ${arr}`);
const values = await this.client.mget(arr);
return {
list: await Promise.all(
arr.map(async (k) => await this.get(k, CacheGetType.TYPE_OBJECT)),
),
list: values.map((res) => {
try {
const o = JSON.parse(res);
if (typeof o === 'object') {
return o;
}
} catch (e) {
return res;
}
return res;
}),
isNoneList,
};
}

Loading…
Cancel
Save