From 8ae2a4f5019ec59aa52810ecf29cb4e369c48862 Mon Sep 17 00:00:00 2001 From: mertmit Date: Fri, 19 Jan 2024 14:19:26 +0000 Subject: [PATCH] fix: deprecate delAll command --- packages/nocodb/src/cache/CacheMgr.ts | 1 - packages/nocodb/src/cache/NocoCache.ts | 5 ----- packages/nocodb/src/cache/RedisCacheMgr.ts | 19 ------------------ .../nocodb/src/cache/RedisMockCacheMgr.ts | 20 ------------------- packages/nocodb/src/models/Column.ts | 4 ---- packages/nocodb/src/models/Model.ts | 5 ----- packages/nocodb/src/models/Sort.ts | 1 - 7 files changed, 55 deletions(-) diff --git a/packages/nocodb/src/cache/CacheMgr.ts b/packages/nocodb/src/cache/CacheMgr.ts index 09bf885efa..9ffd6c5a6b 100644 --- a/packages/nocodb/src/cache/CacheMgr.ts +++ b/packages/nocodb/src/cache/CacheMgr.ts @@ -8,7 +8,6 @@ export default abstract class CacheMgr { ): Promise; public abstract incrby(key: string, value: number): Promise; public abstract del(key: string[] | string): Promise; - public abstract delAll(scope: string, pattern: string): Promise; public abstract getList( scope: string, list: string[], diff --git a/packages/nocodb/src/cache/NocoCache.ts b/packages/nocodb/src/cache/NocoCache.ts index dbd8cadf33..bee205f844 100644 --- a/packages/nocodb/src/cache/NocoCache.ts +++ b/packages/nocodb/src/cache/NocoCache.ts @@ -57,11 +57,6 @@ export default class NocoCache { return this.client.del(`${this.prefix}:${key}`); } - public static async delAll(scope: string, pattern: string): Promise { - if (this.cacheDisabled) return Promise.resolve([]); - return this.client.delAll(scope, pattern); - } - public static async getList( scope: string, subKeys: string[], diff --git a/packages/nocodb/src/cache/RedisCacheMgr.ts b/packages/nocodb/src/cache/RedisCacheMgr.ts index 5e52c8f007..697a5c74e5 100644 --- a/packages/nocodb/src/cache/RedisCacheMgr.ts +++ b/packages/nocodb/src/cache/RedisCacheMgr.ts @@ -126,25 +126,6 @@ export default class RedisCacheMgr extends CacheMgr { return this.client.incrby(key, value); } - // @ts-ignore - async delAll(scope: string, pattern: string): Promise { - // Example: nc::model:*: - const keys = await this.client.keys(`${this.prefix}:${scope}:${pattern}`); - log( - `RedisCacheMgr::delAll: deleting all keys with pattern ${this.prefix}:${scope}:${pattern}`, - ); - await Promise.all( - keys.map(async (k) => { - await this.deepDel(scope, k, CacheDelDirection.CHILD_TO_PARENT); - }), - ); - return Promise.all( - keys.map(async (k) => { - await this.del(k); - }), - ); - } - async getList( scope: string, subKeys: string[], diff --git a/packages/nocodb/src/cache/RedisMockCacheMgr.ts b/packages/nocodb/src/cache/RedisMockCacheMgr.ts index db45b29ae6..7478a0e93f 100644 --- a/packages/nocodb/src/cache/RedisMockCacheMgr.ts +++ b/packages/nocodb/src/cache/RedisMockCacheMgr.ts @@ -123,26 +123,6 @@ export default class RedisMockCacheMgr extends CacheMgr { return this.client.incrby(key, value); } - // @ts-ignore - async delAll(scope: string, pattern: string): Promise { - // Example: nc::model:*: - const keys = await this.client.keys(`${this.prefix}:${scope}:${pattern}`); - log( - `RedisMockCacheMgr::delAll: deleting all keys with pattern ${this.prefix}:${scope}:${pattern}`, - ); - await Promise.all( - keys.map( - async (k) => - await this.deepDel(scope, k, CacheDelDirection.CHILD_TO_PARENT), - ), - ); - return Promise.all( - keys.map(async (k) => { - await this.del(k); - }), - ); - } - async getList( scope: string, subKeys: string[], diff --git a/packages/nocodb/src/models/Column.ts b/packages/nocodb/src/models/Column.ts index a2670acca7..fdbe298303 100644 --- a/packages/nocodb/src/models/Column.ts +++ b/packages/nocodb/src/models/Column.ts @@ -499,10 +499,6 @@ export default class Column implements ColumnType { ); } - public static async clear({ id }) { - await NocoCache.delAll(CacheScope.COLUMN, `*${id}*`); - } - public static async list( { fk_model_id, diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index e7d4e8f89a..daec022b3c 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -275,11 +275,6 @@ export default class Model implements TableType { return modelList.map((m) => new Model(m)); } - public static async clear({ id }: { id: string }): Promise { - await NocoCache.delAll(CacheScope.MODEL, `*${id}*`); - await Column.clearList({ fk_model_id: id }); - } - public static async get(id: string, ncMeta = Noco.ncMeta): Promise { let modelData = id && diff --git a/packages/nocodb/src/models/Sort.ts b/packages/nocodb/src/models/Sort.ts index d10750695c..a23aa7812d 100644 --- a/packages/nocodb/src/models/Sort.ts +++ b/packages/nocodb/src/models/Sort.ts @@ -91,7 +91,6 @@ export default class Sort { order: 'asc', }, }); - await NocoCache.delAll(CacheScope.SORT, `${sortObj.fk_view_id}:*`); await NocoCache.setList(CacheScope.SORT, [sortObj.fk_view_id], sortList); } else { await NocoCache.appendToList(