-
Notifications
You must be signed in to change notification settings - Fork 4
修复事务同步执行删除缓存问题 #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
修复事务同步执行删除缓存问题 #23
Conversation
return result | ||
}) | ||
|
||
if (clearCacheNsps.length > 0) { await this.cache.mDelete(clearCacheNsps) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
考虑下这句话能不能放到上面18行的位置,是否有必要在事务外面执行
|
||
async getById(id: string, pick = this.columns, trx?: CoaMysql.Transaction, ms = this.ms, force = false) { | ||
const result = await this.redisCache.warp(this.getCacheNsp('id'), id, async () => await super.getById(id, this.columns, trx), ms, force) | ||
const result = trx ? await super.getById(id, this.columns, trx) : await this.redisCache.warp(this.getCacheNsp('id'), id, async () => await super.getById(id, this.columns, trx), ms, force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有问题:
1、直接判断是不是 trx 太简单了,一改所有的代码都有影响,我们新加一个 safeTransaction 的目的就是平滑迁移,自由 safeTransaction 的方法才会使用新的逻辑,下面有几个都是一样,都需要改
2、还有一个这个场景的问题需要考量,等你改完再讨论
|
||
protected async deleteCache(ids: string[], dataList: Array<CoaMysql.SafePartial<Scheme>>) { | ||
async deleteCache(ids: string[], dataList: Array<CoaMysql.SafePartial<Scheme>>, trx?: CoaMysql.Transaction) { | ||
if (trx && !(trx as any).clearCacheNsps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上面,这些逻辑的判断都有问题
No description provided.