From 29a3f7e7c4f9ede186a1382c2831cd6660b9b06d Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 25 Apr 2025 16:15:00 +0800 Subject: [PATCH] format code and add session level prepare stmt config --- gorm.go | 4 +++- internal/lru/lru.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gorm.go b/gorm.go index 15dec58a..dd1940ce 100644 --- a/gorm.go +++ b/gorm.go @@ -110,6 +110,8 @@ type DB struct { type Session struct { DryRun bool PrepareStmt bool + PrepareStmtMaxSize int + PrepareStmtTTL time.Duration NewDB bool Initialized bool SkipHooks bool @@ -273,7 +275,7 @@ func (db *DB) Session(config *Session) *DB { if v, ok := db.cacheStore.Load(preparedStmtDBKey); ok { preparedStmt = v.(*PreparedStmtDB) } else { - preparedStmt = NewPreparedStmtDB(db.ConnPool, db.Config.PrepareStmtMaxSize, db.Config.PrepareStmtTTL) + preparedStmt = NewPreparedStmtDB(db.ConnPool, config.PrepareStmtMaxSize, config.PrepareStmtTTL) db.cacheStore.Store(preparedStmtDBKey, preparedStmt) } diff --git a/internal/lru/lru.go b/internal/lru/lru.go index fbdffbba..4f21589a 100644 --- a/internal/lru/lru.go +++ b/internal/lru/lru.go @@ -1,7 +1,7 @@ package lru // golang -lru -//https://github.com/hashicorp/golang-lru +// https://github.com/hashicorp/golang-lru import ( "sync" "time" @@ -226,7 +226,7 @@ func (c *LRU[K, V]) KeyValues() map[K]V { continue } maps[ent.Key] = ent.Value - //keys = append(keys, ent.Key) + // keys = append(keys, ent.Key) } return maps }