Introduce Exec interface and implementers (#1)
Go Tests / test (push) Failing after 6s

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-05-11 06:03:40 +00:00
parent dedbcc4cfe
commit ffd9cd004e
16 changed files with 1026 additions and 585 deletions
+47
View File
@@ -0,0 +1,47 @@
package cache
import (
"sync"
"git.gdulai.com/gdulai/simpleorm/schema"
)
type SchemaCache struct {
mu sync.RWMutex
data map[string]*schema.Table
}
func NewSchemaCache(tables []*schema.Table) *SchemaCache {
cache := &SchemaCache{
data: make(map[string]*schema.Table),
}
for _, table := range tables {
cache.add(table)
}
return cache
}
func (o *SchemaCache) add(table *schema.Table) {
o.mu.Lock()
defer o.mu.Unlock()
o.data[table.Type.Name()] = table
}
func (o *SchemaCache) Get(typeName string) (*schema.Table, bool) {
o.mu.RLock()
defer o.mu.RUnlock()
table, ok := o.data[typeName]
return table, ok
}
func (o *SchemaCache) GetAll() []*schema.Table {
o.mu.RLock()
defer o.mu.RUnlock()
var result []*schema.Table
for _, v := range o.data {
result = append(result, v)
}
return result
}