Skip to content

Commit bde8b21

Browse files
committed
Added cache control methods to store template
1 parent 6666a88 commit bde8b21

File tree

3 files changed

+251
-1
lines changed

3 files changed

+251
-1
lines changed

generator/templates/model.tgo

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ func (s *{{.StoreName}}) DebugWith(logger kallax.LoggerFunc) *{{.StoreName}} {
118118
return &{{.StoreName}}{s.Store.DebugWith(logger)}
119119
}
120120

121+
// DisableCacher turns off prepared statements, which can be useful in some scenarios.
122+
func (s *{{.StoreName}}) DisableCacher() *{{.StoreName}} {
123+
return &{{.StoreName}}{s.Store.DisableCacher()}
124+
}
125+
126+
// DisableCacher turns on prepared statements. This is the default.
127+
func (s *{{.StoreName}}) EnableCacher() *{{.StoreName}} {
128+
return &{{.StoreName}}{s.Store.EnableCacher()}
129+
}
130+
121131
{{if .HasNonInverses}}
122132
func (s *{{.StoreName}}) relationshipRecords(record *{{.Name}}) []modelSaveFunc {
123133
var result []modelSaveFunc

store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (s *Store) DebugWith(logger LoggerFunc) *Store {
159159
}).init()
160160
}
161161

162-
// DisableCacher turns off prepared statements.
162+
// DisableCacher turns off prepared statements, which can be useful in some scenarios.
163163
func (s *Store) DisableCacher() *Store {
164164
return (&Store{
165165
db: s.db,

0 commit comments

Comments
 (0)