Browse Source

fix: append to list fallback

pull/7464/head
mertmit 11 months ago
parent
commit
dace72b75e
  1. 17
      packages/nocodb/src/cache/RedisCacheMgr.ts
  2. 17
      packages/nocodb/src/cache/RedisMockCacheMgr.ts

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

@ -307,8 +307,23 @@ export default class RedisCacheMgr extends CacheMgr {
const value = await this.get(key, CacheGetType.TYPE_OBJECT);
log(`RedisCacheMgr::appendToList: preparing key ${key}`);
if (!value) {
// FALLBACK: this is to get rid of all keys that would be effected by this (should never happen)
console.error(`RedisCacheMgr::appendToList: value is empty for ${key}`);
await this.del(listKey);
const allParents = [];
// get all children
const listValues = await this.getList(scope, subListKeys);
// get all parents from children
listValues.list.forEach((v) => {
allParents.push(...this.getParents(v));
});
// remove duplicates
const uniqueParents = [...new Set(allParents)];
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return false;
}
// prepare Get Key

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

@ -304,10 +304,25 @@ export default class RedisMockCacheMgr extends CacheMgr {
const value = await this.get(key, CacheGetType.TYPE_OBJECT);
log(`RedisMockCacheMgr::appendToList: preparing key ${key}`);
if (!value) {
// FALLBACK: this is to get rid of all keys that would be effected by this (should never happen)
console.error(
`RedisMockCacheMgr::appendToList: value is empty for ${key}`,
);
await this.del(listKey);
const allParents = [];
// get all children
const listValues = await this.getList(scope, subListKeys);
// get all parents from children
listValues.list.forEach((v) => {
allParents.push(...this.getParents(v));
});
// remove duplicates
const uniqueParents = [...new Set(allParents)];
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return false;
}
// prepare Get Key

Loading…
Cancel
Save