diff --git a/template/stmt.go b/template/stmt.go index 0616092..56d2479 100644 --- a/template/stmt.go +++ b/template/stmt.go @@ -90,34 +90,9 @@ func (s *customCacheStatement) Exec(args []driver.Value) (driver.Result, error) func execInsert(queryInfo domains.CachePlanQuery, args []driver.Value) { table := queryInfo.Insert.Table - normalizedArgs, _ := normalizer.NormalizeArgs(queryInfo.Query) - - rows := slices.Chunk(args, len(queryInfo.Insert.Columns)) for _, cache := range cacheByTable[table] { - if cache.uniqueOnly { - // no need to purge - continue - } - - selectConditions := cache.info.Conditions - if len(selectConditions) != 1 || len(normalizedArgs.ExtraArgs) != 0 || selectConditions[0].Operator != domains.CachePlanOperator_EQ { - cache.cache.Purge() - continue - } - - selectCondition := selectConditions[0] - insertColumnIdx := slices.Index(queryInfo.Insert.Columns, selectCondition.Column) - if insertColumnIdx >= 0 { - // insert query is like "INSERT INTO table (col1, col2, ...) VALUES (?, ?, ...)" - // select query is like "SELECT * FROM table WHERE col1 = ?" - // forget the cache - for row := range rows { - cache.cache.Forget(cacheKey([]driver.Value{row[insertColumnIdx]})) - } - } else { - cache.cache.Purge() - } + cache.cache.Purge() } } diff --git a/template/stmt.tmpl b/template/stmt.tmpl index b44ad2e..7629fb8 100644 --- a/template/stmt.tmpl +++ b/template/stmt.tmpl @@ -90,34 +90,9 @@ func (s *customCacheStatement) Exec(args []driver.Value) (driver.Result, error) func execInsert(queryInfo domains.CachePlanQuery, args []driver.Value) { table := queryInfo.Insert.Table - normalizedArgs, _ := normalizer.NormalizeArgs(queryInfo.Query) - - rows := slices.Chunk(args, len(queryInfo.Insert.Columns)) for _, cache := range cacheByTable[table] { - if cache.uniqueOnly { - // no need to purge - continue - } - - selectConditions := cache.info.Conditions - if len(selectConditions) != 1 || len(normalizedArgs.ExtraArgs) != 0 || selectConditions[0].Operator != domains.CachePlanOperator_EQ { - cache.cache.Purge() - continue - } - - selectCondition := selectConditions[0] - insertColumnIdx := slices.Index(queryInfo.Insert.Columns, selectCondition.Column) - if insertColumnIdx >= 0 { - // insert query is like "INSERT INTO table (col1, col2, ...) VALUES (?, ?, ...)" - // select query is like "SELECT * FROM table WHERE col1 = ?" - // forget the cache - for row := range rows { - cache.cache.Forget(cacheKey([]driver.Value{row[insertColumnIdx]})) - } - } else { - cache.cache.Purge() - } + cache.cache.Purge() } }