Browse Source

refactor: get rid of unused scope arg of deepDel

pull/7596/head
mertmit 7 months ago
parent
commit
786142c640
  1. 6
      packages/nocodb/src/cache/CacheMgr.ts
  2. 3
      packages/nocodb/src/cache/NocoCache.ts
  3. 10
      packages/nocodb/src/cache/RedisCacheMgr.ts
  4. 10
      packages/nocodb/src/cache/RedisMockCacheMgr.ts
  5. 1
      packages/nocodb/src/models/ApiToken.ts
  6. 2
      packages/nocodb/src/models/Base.ts
  7. 14
      packages/nocodb/src/models/Column.ts
  8. 3
      packages/nocodb/src/models/Filter.ts
  9. 2
      packages/nocodb/src/models/Hook.ts
  10. 2
      packages/nocodb/src/models/HookFilter.ts
  11. 4
      packages/nocodb/src/models/Model.ts
  12. 1
      packages/nocodb/src/models/ModelRoleVisibility.ts
  13. 2
      packages/nocodb/src/models/Sort.ts
  14. 3
      packages/nocodb/src/models/Source.ts
  15. 2
      packages/nocodb/src/models/User.ts
  16. 3
      packages/nocodb/src/models/View.ts
  17. 2
      packages/nocodb/src/utils/globals.ts

6
packages/nocodb/src/cache/CacheMgr.ts vendored

@ -21,11 +21,7 @@ export default abstract class CacheMgr {
list: any[],
props?: string[],
): Promise<boolean>;
public abstract deepDel(
scope: string,
key: string,
direction: string,
): Promise<boolean>;
public abstract deepDel(key: string, direction: string): Promise<boolean>;
public abstract appendToList(
scope: string,
subListKeys: string[],

3
packages/nocodb/src/cache/NocoCache.ts vendored

@ -85,12 +85,11 @@ export default class NocoCache {
}
public static async deepDel(
scope: string,
key: string,
direction: string,
): Promise<boolean> {
if (this.cacheDisabled) return Promise.resolve(true);
return this.client.deepDel(scope, `${this.prefix}:${key}`, direction);
return this.client.deepDel(`${this.prefix}:${key}`, direction);
}
public static async appendToList(

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

@ -182,7 +182,7 @@ export default class RedisCacheMgr extends CacheMgr {
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
await this.deepDel(p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return Promise.resolve({
@ -257,11 +257,7 @@ export default class RedisCacheMgr extends CacheMgr {
return this.set(listKey, listOfGetKeys);
}
async deepDel(
scope: string,
key: string,
direction: string,
): Promise<boolean> {
async deepDel(key: string, direction: string): Promise<boolean> {
log(`RedisCacheMgr::deepDel: choose direction ${direction}`);
if (direction === CacheDelDirection.CHILD_TO_PARENT) {
const childKey = await this.get(key, CacheGetType.TYPE_OBJECT);
@ -343,7 +339,7 @@ export default class RedisCacheMgr extends CacheMgr {
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
await this.deepDel(p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return false;

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

@ -179,7 +179,7 @@ export default class RedisMockCacheMgr extends CacheMgr {
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
await this.deepDel(p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return Promise.resolve({
@ -254,11 +254,7 @@ export default class RedisMockCacheMgr extends CacheMgr {
return this.set(listKey, listOfGetKeys);
}
async deepDel(
scope: string,
key: string,
direction: string,
): Promise<boolean> {
async deepDel(key: string, direction: string): Promise<boolean> {
log(`RedisMockCacheMgr::deepDel: choose direction ${direction}`);
if (direction === CacheDelDirection.CHILD_TO_PARENT) {
const childKey = await this.get(key, CacheGetType.TYPE_OBJECT);
@ -342,7 +338,7 @@ export default class RedisMockCacheMgr extends CacheMgr {
// delete all parents and children
await Promise.all(
uniqueParents.map(async (p) => {
await this.deepDel(scope, p, CacheDelDirection.PARENT_TO_CHILD);
await this.deepDel(p, CacheDelDirection.PARENT_TO_CHILD);
}),
);
return false;

1
packages/nocodb/src/models/ApiToken.ts

@ -56,7 +56,6 @@ export default class ApiToken implements ApiTokenType {
static async delete(token, ncMeta = Noco.ncMeta) {
await NocoCache.deepDel(
CacheScope.API_TOKEN,
`${CacheScope.API_TOKEN}:${token}`,
CacheDelDirection.CHILD_TO_PARENT,
);

2
packages/nocodb/src/models/Base.ts

@ -240,7 +240,6 @@ export default class Base implements BaseType {
// remove item in cache list
await NocoCache.deepDel(
CacheScope.PROJECT,
`${CacheScope.PROJECT}:${baseId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -353,7 +352,6 @@ export default class Base implements BaseType {
}
await NocoCache.deepDel(
CacheScope.PROJECT,
`${CacheScope.PROJECT}:${baseId}`,
CacheDelDirection.CHILD_TO_PARENT,
);

14
packages/nocodb/src/models/Column.ts

@ -481,7 +481,6 @@ export default class Column<T = any> implements ColumnType {
public static async clearList({ fk_model_id }) {
await NocoCache.deepDel(
CacheScope.COLUMN,
`${CacheScope.COLUMN}:${fk_model_id}:list`,
CacheDelDirection.PARENT_TO_CHILD,
);
@ -822,7 +821,6 @@ export default class Column<T = any> implements ColumnType {
fk_column_id: col.id,
});
await NocoCache.deepDel(
cacheScopeName,
`${cacheScopeName}:${col.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -838,7 +836,6 @@ export default class Column<T = any> implements ColumnType {
);
if (gridViewColumnId) {
await NocoCache.deepDel(
CacheScope.GRID_VIEW_COLUMN,
`${CacheScope.GRID_VIEW_COLUMN}:${gridViewColumnId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -854,7 +851,6 @@ export default class Column<T = any> implements ColumnType {
);
if (formViewColumnId) {
await NocoCache.deepDel(
CacheScope.FORM_VIEW_COLUMN,
`${CacheScope.FORM_VIEW_COLUMN}:${formViewColumnId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -870,7 +866,6 @@ export default class Column<T = any> implements ColumnType {
);
if (kanbanViewColumnId) {
await NocoCache.deepDel(
CacheScope.KANBAN_VIEW_COLUMN,
`${CacheScope.KANBAN_VIEW_COLUMN}:${kanbanViewColumnId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -886,7 +881,6 @@ export default class Column<T = any> implements ColumnType {
);
if (galleryViewColumnId) {
await NocoCache.deepDel(
CacheScope.GALLERY_VIEW_COLUMN,
`${CacheScope.GALLERY_VIEW_COLUMN}:${galleryViewColumnId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -917,7 +911,6 @@ export default class Column<T = any> implements ColumnType {
// Columns
await ncMeta.metaDelete(null, null, MetaTable.COLUMNS, col.id);
await NocoCache.deepDel(
CacheScope.COLUMN,
`${CacheScope.COLUMN}:${col.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -944,7 +937,6 @@ export default class Column<T = any> implements ColumnType {
fk_column_id: colId,
});
await NocoCache.deepDel(
CacheScope.COL_LOOKUP,
`${CacheScope.COL_LOOKUP}:${colId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -955,7 +947,6 @@ export default class Column<T = any> implements ColumnType {
fk_column_id: colId,
});
await NocoCache.deepDel(
CacheScope.COL_ROLLUP,
`${CacheScope.COL_ROLLUP}:${colId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -967,7 +958,6 @@ export default class Column<T = any> implements ColumnType {
fk_column_id: colId,
});
await NocoCache.deepDel(
CacheScope.COL_RELATION,
`${CacheScope.COL_RELATION}:${colId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -979,7 +969,6 @@ export default class Column<T = any> implements ColumnType {
});
await NocoCache.deepDel(
CacheScope.COL_FORMULA,
`${CacheScope.COL_FORMULA}:${colId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -991,7 +980,6 @@ export default class Column<T = any> implements ColumnType {
});
await NocoCache.deepDel(
CacheScope.COL_QRCODE,
`${CacheScope.COL_QRCODE}:${colId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -1004,7 +992,6 @@ export default class Column<T = any> implements ColumnType {
});
await NocoCache.deepDel(
CacheScope.COL_BARCODE,
`${CacheScope.COL_BARCODE}:${colId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -1018,7 +1005,6 @@ export default class Column<T = any> implements ColumnType {
});
await NocoCache.deepDel(
CacheScope.COL_SELECT_OPTION,
`${CacheScope.COL_SELECT_OPTION}:${colId}:list`,
CacheDelDirection.PARENT_TO_CHILD,
);

3
packages/nocodb/src/models/Filter.ts

@ -276,7 +276,6 @@ export default class Filter implements FilterType {
await deleteRecursively(f);
await ncMeta.metaDelete(null, null, MetaTable.FILTER_EXP, filter.id);
await NocoCache.deepDel(
CacheScope.FILTER_EXP,
`${CacheScope.FILTER_EXP}:${filter.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -435,7 +434,6 @@ export default class Filter implements FilterType {
if (filter.id) {
await ncMeta.metaDelete(null, null, MetaTable.FILTER_EXP, filter.id);
await NocoCache.deepDel(
CacheScope.FILTER_EXP,
`${CacheScope.FILTER_EXP}:${filter.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -459,7 +457,6 @@ export default class Filter implements FilterType {
if (filter.id) {
await ncMeta.metaDelete(null, null, MetaTable.FILTER_EXP, filter.id);
await NocoCache.deepDel(
CacheScope.FILTER_EXP,
`${CacheScope.FILTER_EXP}:${filter.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);

2
packages/nocodb/src/models/Hook.ts

@ -238,7 +238,6 @@ export default class Hook implements HookType {
);
for (const filter of filterList) {
await NocoCache.deepDel(
CacheScope.FILTER_EXP,
`${CacheScope.FILTER_EXP}:${filter.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -246,7 +245,6 @@ export default class Hook implements HookType {
}
// Delete Hook
await NocoCache.deepDel(
CacheScope.HOOK,
`${CacheScope.HOOK}:${hookId}`,
CacheDelDirection.CHILD_TO_PARENT,
);

2
packages/nocodb/src/models/HookFilter.ts

@ -174,7 +174,6 @@ export default class Filter {
await deleteRecursively(f);
await ncMeta.metaDelete(null, null, MetaTable.FILTER_EXP, filter.id);
await NocoCache.deepDel(
CacheScope.FILTER_EXP,
`${CacheScope.FILTER_EXP}:${filter.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -307,7 +306,6 @@ export default class Filter {
// if (filter.id) {
// await ncMeta.metaDelete(null, null, MetaTable.FILTER_EXP, filter.id);
// await NocoCache.deepDel(
// CacheScope.FILTER_EXP,
// `${CacheScope.FILTER_EXP}:${filter.id}`,
// CacheDelDirection.CHILD_TO_PARENT
// );

4
packages/nocodb/src/models/Model.ts

@ -463,7 +463,6 @@ export default class Model implements TableType {
fk_column_id: col.id,
});
await NocoCache.deepDel(
cacheScopeName,
`${cacheScopeName}:${col.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -484,7 +483,6 @@ export default class Model implements TableType {
for (const col of leftOverColumns) {
await NocoCache.deepDel(
CacheScope.COL_RELATION,
`${CacheScope.COL_RELATION}:${col.fk_column_id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -496,7 +494,6 @@ export default class Model implements TableType {
}
await NocoCache.deepDel(
CacheScope.COLUMN,
`${CacheScope.COLUMN}:${this.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -505,7 +502,6 @@ export default class Model implements TableType {
});
await NocoCache.deepDel(
CacheScope.MODEL,
`${CacheScope.MODEL}:${this.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);

1
packages/nocodb/src/models/ModelRoleVisibility.ts

@ -124,7 +124,6 @@ export default class ModelRoleVisibility implements ModelRoleVisibilityType {
},
);
await NocoCache.deepDel(
CacheScope.MODEL_ROLE_VISIBILITY,
`${CacheScope.MODEL_ROLE_VISIBILITY}:${fk_view_id}:${role}`,
CacheDelDirection.CHILD_TO_PARENT,
);

2
packages/nocodb/src/models/Sort.ts

@ -27,7 +27,6 @@ export default class Sort {
public static async deleteAll(viewId: string, ncMeta = Noco.ncMeta) {
await NocoCache.deepDel(
CacheScope.SORT,
`${CacheScope.SORT}:${viewId}`,
CacheDelDirection.PARENT_TO_CHILD,
);
@ -187,7 +186,6 @@ export default class Sort {
await ncMeta.metaDelete(null, null, MetaTable.SORT, sortId);
await NocoCache.deepDel(
CacheScope.SORT,
`${CacheScope.SORT}:${sortId}`,
CacheDelDirection.CHILD_TO_PARENT,
);

3
packages/nocodb/src/models/Source.ts

@ -414,7 +414,6 @@ export default class Source implements SourceType {
fk_column_id: relCol.col.id,
});
await NocoCache.deepDel(
relCol.cacheScopeName,
`${relCol.cacheScopeName}:${relCol.col.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -434,7 +433,6 @@ export default class Source implements SourceType {
const res = await ncMeta.metaDelete(null, null, MetaTable.BASES, this.id);
await NocoCache.deepDel(
CacheScope.BASE,
`${CacheScope.BASE}:${this.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);
@ -460,7 +458,6 @@ export default class Source implements SourceType {
);
await NocoCache.deepDel(
CacheScope.BASE,
`${CacheScope.BASE}:${this.id}`,
CacheDelDirection.CHILD_TO_PARENT,
);

2
packages/nocodb/src/models/User.ts

@ -75,7 +75,6 @@ export default class User implements UserType {
const bases = await Base.list({}, ncMeta);
for (const base of bases) {
await NocoCache.deepDel(
CacheScope.BASE_USER,
`${CacheScope.BASE_USER}:${base.id}:list`,
CacheDelDirection.PARENT_TO_CHILD,
);
@ -299,7 +298,6 @@ export default class User implements UserType {
for (const base of bases) {
await NocoCache.deepDel(
CacheScope.BASE_USER,
`${CacheScope.BASE_USER}:${base.id}:list`,
CacheDelDirection.PARENT_TO_CHILD,
);

3
packages/nocodb/src/models/View.ts

@ -1139,17 +1139,14 @@ export default class View implements ViewType {
});
await ncMeta.metaDelete(null, null, MetaTable.VIEWS, viewId);
await NocoCache.deepDel(
tableScope,
`${tableScope}:${viewId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
await NocoCache.deepDel(
columnTableScope,
`${columnTableScope}:${viewId}`,
CacheDelDirection.CHILD_TO_PARENT,
);
await NocoCache.deepDel(
CacheScope.VIEW,
`${CacheScope.VIEW}:${viewId}`,
CacheDelDirection.CHILD_TO_PARENT,
);

2
packages/nocodb/src/utils/globals.ts

@ -178,6 +178,8 @@ export enum CacheDelDirection {
export const CacheListProp = '__nc_list__';
export const CacheTimeProp = '__nc_time__';
export const GROUPBY_COMPARISON_OPS = <const>[
// these are used for groupby
'gb_eq',

Loading…
Cancel
Save