Stops the cache. Clears its state and tells the housekeeping task to stop.
(ctx context.Context)
| 213 | |
| 214 | // Stops the cache. Clears its state and tells the housekeeping task to stop. |
| 215 | func (c *changeCache) Stop(ctx context.Context) { |
| 216 | |
| 217 | if !c.started.IsTrue() { |
| 218 | // changeCache never started - nothing to stop |
| 219 | return |
| 220 | } |
| 221 | |
| 222 | if !c.stopped.CompareAndSwap(false, true) { |
| 223 | base.WarnfCtx(ctx, "changeCache was already stopped") |
| 224 | return |
| 225 | } |
| 226 | |
| 227 | // Signal to background goroutines that the changeCache has been stopped, so they can exit |
| 228 | // their loop |
| 229 | close(c.terminator) |
| 230 | |
| 231 | // Wait for changeCache background tasks to finish. |
| 232 | waitForBGTCompletion(ctx, BGTCompletionMaxWait, c.backgroundTasks, c.db.Name) |
| 233 | |
| 234 | c.lock.Lock() |
| 235 | c.logsDisabled = true |
| 236 | c.lock.Unlock() |
| 237 | } |
| 238 | |
| 239 | // Empty out all channel caches. |
| 240 | func (c *changeCache) Clear(ctx context.Context) error { |