只使用lru

This commit is contained in:
xiezhaodong 2025-04-24 16:36:55 +08:00
parent 4be2fdb497
commit 3758fb9de2

View File

@ -88,7 +88,7 @@ func (db *PreparedStmtDB) Close() {
return return
} }
for _, stmt := range db.Stmts.allMap() { for _, stmt := range db.Stmts.AllMap() {
go func(s *Stmt) { go func(s *Stmt) {
// make sure the stmt must finish preparation first // make sure the stmt must finish preparation first
<-s.prepared <-s.prepared
@ -107,7 +107,7 @@ func (sdb *PreparedStmtDB) Reset() {
if sdb.Stmts == nil { if sdb.Stmts == nil {
return return
} }
for _, stmt := range sdb.Stmts.allMap() { for _, stmt := range sdb.Stmts.AllMap() {
go func(s *Stmt) { go func(s *Stmt) {
// make sure the stmt must finish preparation first // make sure the stmt must finish preparation first
<-s.prepared <-s.prepared
@ -330,7 +330,7 @@ type StmtStore interface {
get(key string) (*Stmt, bool) get(key string) (*Stmt, bool)
set(key string, value *Stmt) set(key string, value *Stmt)
delete(key string) delete(key string)
allMap() map[string]*Stmt AllMap() map[string]*Stmt
} }
/* /*
@ -386,7 +386,7 @@ func (s *LruStmtStore) newLru(size int, ttl time.Duration) {
s.lru = lru.NewLRU[string, *Stmt](size, onEvicted, ttl) s.lru = lru.NewLRU[string, *Stmt](size, onEvicted, ttl)
} }
func (s *LruStmtStore) allMap() map[string]*Stmt { func (s *LruStmtStore) AllMap() map[string]*Stmt {
return s.lru.KeyValues() return s.lru.KeyValues()
} }
func (s *LruStmtStore) get(key string) (*Stmt, bool) { func (s *LruStmtStore) get(key string) (*Stmt, bool) {