|
|
@ -37,7 +37,13 @@ export default class RedisMockCacheMgr extends CacheMgr { |
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
async del(key: string[] | string): Promise<any> { |
|
|
|
async del(key: string[] | string): Promise<any> { |
|
|
|
log(`RedisMockCacheMgr::del: deleting key ${key}`); |
|
|
|
log(`RedisMockCacheMgr::del: deleting key ${key}`); |
|
|
|
return this.client.del(Array.isArray(key) ? key : [key]); |
|
|
|
if (Array.isArray(key)) { |
|
|
|
|
|
|
|
if (key.length) { |
|
|
|
|
|
|
|
return this.client.del(key); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (key) { |
|
|
|
|
|
|
|
return this.client.del(key); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
@ -220,7 +226,6 @@ export default class RedisMockCacheMgr extends CacheMgr { |
|
|
|
if (list.length) { |
|
|
|
if (list.length) { |
|
|
|
// set target list
|
|
|
|
// set target list
|
|
|
|
log(`RedisMockCacheMgr::deepDel: set key ${listKey}`); |
|
|
|
log(`RedisMockCacheMgr::deepDel: set key ${listKey}`); |
|
|
|
await this.del(listKey); |
|
|
|
|
|
|
|
await this.set(listKey, list); |
|
|
|
await this.set(listKey, list); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -231,7 +236,7 @@ export default class RedisMockCacheMgr extends CacheMgr { |
|
|
|
// given a list key, delete all the children
|
|
|
|
// given a list key, delete all the children
|
|
|
|
const listOfChildren = await this.get(key, CacheGetType.TYPE_ARRAY); |
|
|
|
const listOfChildren = await this.get(key, CacheGetType.TYPE_ARRAY); |
|
|
|
// delete each child key
|
|
|
|
// delete each child key
|
|
|
|
await Promise.all(listOfChildren.map(async (k) => await this.del(k))); |
|
|
|
await this.del(listOfChildren); |
|
|
|
// delete list key
|
|
|
|
// delete list key
|
|
|
|
return await this.del(key); |
|
|
|
return await this.del(key); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|