@@ -154,16 +154,6 @@ func (e *Executor) runOnce(t time.Time) Stats {
154
154
// Limit the concurrency to avoid overloading the database.
155
155
eg .SetLimit (10 )
156
156
157
- // We cache these values to help reduce load on the database.
158
- // These could be outdated during our execution, but this is
159
- // unlikely to be noticed or cause any unwanted behaviour.
160
- var (
161
- userCache = newCacheOf [uuid.UUID , database.User ]()
162
- templateCache = newCacheOf [uuid.UUID , database.Template ]()
163
- templateVersionCache = newCacheOf [uuid.UUID , database.TemplateVersion ]()
164
- templateScheduleCache = newCacheOf [uuid.UUID , schedule.TemplateScheduleOptions ]()
165
- )
166
-
167
157
for _ , ws := range workspaces {
168
158
wsID := ws .ID
169
159
wsName := ws .Name
@@ -194,9 +184,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
194
184
return xerrors .Errorf ("get workspace by id: %w" , err )
195
185
}
196
186
197
- user , err := userCache .LoadOrStore (ws .OwnerID , func () (database.User , error ) {
198
- return tx .GetUserByID (e .ctx , ws .OwnerID )
199
- })
187
+ user , err := tx .GetUserByID (e .ctx , ws .OwnerID )
200
188
if err != nil {
201
189
return xerrors .Errorf ("get user by id: %w" , err )
202
190
}
@@ -212,23 +200,17 @@ func (e *Executor) runOnce(t time.Time) Stats {
212
200
return xerrors .Errorf ("get latest provisioner job: %w" , err )
213
201
}
214
202
215
- templateSchedule , err := templateScheduleCache .LoadOrStore (ws .TemplateID , func () (schedule.TemplateScheduleOptions , error ) {
216
- return (* (e .templateScheduleStore .Load ())).Get (e .ctx , tx , ws .TemplateID )
217
- })
203
+ templateSchedule , err := (* (e .templateScheduleStore .Load ())).Get (e .ctx , tx , ws .TemplateID )
218
204
if err != nil {
219
205
return xerrors .Errorf ("get template scheduling options: %w" , err )
220
206
}
221
207
222
- tmpl , err := templateCache .LoadOrStore (ws .TemplateID , func () (database.Template , error ) {
223
- return tx .GetTemplateByID (e .ctx , ws .TemplateID )
224
- })
208
+ tmpl , err := tx .GetTemplateByID (e .ctx , ws .TemplateID )
225
209
if err != nil {
226
210
return xerrors .Errorf ("get template by ID: %w" , err )
227
211
}
228
212
229
- activeTemplateVersion , err = templateVersionCache .LoadOrStore (tmpl .ActiveVersionID , func () (database.TemplateVersion , error ) {
230
- return tx .GetTemplateVersionByID (e .ctx , tmpl .ActiveVersionID )
231
- })
213
+ activeTemplateVersion , err = tx .GetTemplateVersionByID (e .ctx , tmpl .ActiveVersionID )
232
214
if err != nil {
233
215
return xerrors .Errorf ("get active template version by ID: %w" , err )
234
216
}
0 commit comments