diff --git a/packages/nocodb/src/lib/cache/RedisCacheMgr.ts b/packages/nocodb/src/lib/cache/RedisCacheMgr.ts index 906262a0f2..d970f6b716 100644 --- a/packages/nocodb/src/lib/cache/RedisCacheMgr.ts +++ b/packages/nocodb/src/lib/cache/RedisCacheMgr.ts @@ -2,6 +2,7 @@ import debug from 'debug'; import CacheMgr from './CacheMgr'; import Redis from 'ioredis'; import { CacheDelDirection, CacheGetType, CacheScope } from '../utils/globals'; + const log = debug('nc:cache'); export default class RedisCacheMgr extends CacheMgr { @@ -101,11 +102,15 @@ export default class RedisCacheMgr extends CacheMgr { 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.deepDel(scope, k, CacheDelDirection.CHILD_TO_PARENT) - ) + keys.map(async (k) => { + await this.del(k); + }) ); } diff --git a/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts b/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts index ed941bbd26..902b728bb2 100644 --- a/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts +++ b/packages/nocodb/src/lib/cache/RedisMockCacheMgr.ts @@ -101,12 +101,17 @@ export default class RedisMockCacheMgr extends CacheMgr { log( `RedisMockCacheMgr::delAll: deleting all keys with pattern ${this.prefix}:${scope}:${pattern}` ); - return Promise.all( + 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[]): Promise { diff --git a/packages/nocodb/src/lib/models/ProjectUser.ts b/packages/nocodb/src/lib/models/ProjectUser.ts index 835a3b68c1..c4c7454a31 100644 --- a/packages/nocodb/src/lib/models/ProjectUser.ts +++ b/packages/nocodb/src/lib/models/ProjectUser.ts @@ -36,10 +36,10 @@ export default class ProjectUser { true ); - await NocoCache.appendToList( + // reset all user projects cache + await NocoCache.delAll( CacheScope.USER_PROJECT, - [projectUser.fk_user_id], - `${CacheScope.USER_PROJECT}:${projectUser.project_id}` + `${projectUser.fk_user_id}:*` ); return this.get(project_id, fk_user_id, ncMeta); @@ -236,13 +236,10 @@ export default class ProjectUser { `${MetaTable.PROJECT_USERS}.project_id`, `${MetaTable.PROJECT}.id` ); - - // if (!isSuperAdmin) { this.andOn( `${MetaTable.PROJECT_USERS}.fk_user_id`, ncMeta.knex.raw('?', [userId]) ); - // } }) .where(function () { this.where(`${MetaTable.PROJECT}.deleted`, false).orWhereNull(