From b92ca95e122f2e7cd367d2c48db56de2ebecc1dd Mon Sep 17 00:00:00 2001 From: donnie4w Date: Fri, 18 Oct 2024 20:02:02 +0800 Subject: [PATCH] Update table.go --- table.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/table.go b/table.go index fd1a0c8..ca5cc1d 100644 --- a/table.go +++ b/table.go @@ -394,6 +394,7 @@ func (t *Table[T]) Update() (sql.Result, error) { } if g := t.getDB(false); g != nil { + t.clearExpire() return g.ExecuteUpdate(t.sql, t.args...) } else { return nil, errInit @@ -420,6 +421,7 @@ func (t *Table[T]) Insert() (sql.Result, error) { } if g := t.getDB(false); g != nil { + t.clearExpire() return g.ExecuteUpdate(t.sql, t.args...) } else { return nil, errInit @@ -462,6 +464,7 @@ func (t *Table[T]) ExecBatch() ([]sql.Result, error) { Logger.Debug("[BATCH]["+t.sql+"]", t.batchArgs) } if g := t.getDB(false); g != nil { + t.clearExpire() return g.ExecuteBatch(t.sql, t.batchArgs) } else { return nil, errInit @@ -477,12 +480,17 @@ func (t *Table[T]) Delete() (sql.Result, error) { } if g := t.getDB(false); g != nil { + t.clearExpire() return g.ExecuteUpdate(t.sql, t.args...) } else { return nil, errInit } } +func (t *Table[T]) clearExpire() { + gdaoCache.ClearExpireWrite[T]() +} + var serialize Serialize[map[string]any] = &Serializer{} func (t *Table[T]) Encode(m map[string]any) ([]byte, error) {