Skip to content

Commit fea3f4b

Browse files
committed
fix
1 parent 7797d54 commit fea3f4b

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

template/stmt.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ func (c *cacheConn) execUpdate(ctx context.Context, queryInfo domains.CachePlanQ
237237
}
238238
if !updateByUnique {
239239
for _, cache := range cacheByTable[table] {
240-
if !usedBySelectQuery(cache.info.Targets, queryInfo.Update.Targets) {
241-
// no need to purge because the cache does not contain the updated column
242-
continue
243-
}
244240
// we should purge all cache
245241
cache.cache.Purge()
246242
}
@@ -272,16 +268,9 @@ func (c *cacheConn) execDelete(ctx context.Context, queryInfo domains.CachePlanQ
272268
return inner.ExecContext(ctx, queryInfo.Query, args)
273269
}
274270

275-
uniqueValue := args[queryInfo.Delete.Conditions[0].Placeholder.Index]
276-
277271
for _, cache := range cacheByTable[table] {
278-
if cache.uniqueOnly {
279-
// query like "SELECT * FROM table WHERE pk = ?"
280-
// we should forget the cache
281-
cache.cache.Forget(cacheKey([]driver.Value{uniqueValue.Value}))
282-
} else {
283-
cache.cache.Purge()
284-
}
272+
cache.cache.Purge()
273+
285274
}
286275

287276
return inner.ExecContext(ctx, queryInfo.Query, args)

template/stmt.tmpl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ func (c *cacheConn) execUpdate(ctx context.Context, queryInfo domains.CachePlanQ
237237
}
238238
if !updateByUnique {
239239
for _, cache := range cacheByTable[table] {
240-
if !usedBySelectQuery(cache.info.Targets, queryInfo.Update.Targets) {
241-
// no need to purge because the cache does not contain the updated column
242-
continue
243-
}
244240
// we should purge all cache
245241
cache.cache.Purge()
246242
}
@@ -272,16 +268,9 @@ func (c *cacheConn) execDelete(ctx context.Context, queryInfo domains.CachePlanQ
272268
return inner.ExecContext(ctx, queryInfo.Query, args)
273269
}
274270

275-
uniqueValue := args[queryInfo.Delete.Conditions[0].Placeholder.Index]
276-
277271
for _, cache := range cacheByTable[table] {
278-
if cache.uniqueOnly {
279-
// query like "SELECT * FROM table WHERE pk = ?"
280-
// we should forget the cache
281-
cache.cache.Forget(cacheKey([]driver.Value{uniqueValue.Value}))
282-
} else {
283-
cache.cache.Purge()
284-
}
272+
cache.cache.Purge()
273+
285274
}
286275

287276
return inner.ExecContext(ctx, queryInfo.Query, args)

0 commit comments

Comments
 (0)