Close closes the badger database and stops the background GC goroutine.
()
| 258 | |
| 259 | // Close closes the badger database and stops the background GC goroutine. |
| 260 | func (c *BadgerCache) Close() error { |
| 261 | c.closeOnce.Do(func() { |
| 262 | getCacheLogger().Debug("Closing Badger database") |
| 263 | |
| 264 | if c.stopGC != nil { |
| 265 | close(c.stopGC) |
| 266 | } |
| 267 | |
| 268 | if c.db != nil { |
| 269 | c.closeErr = c.db.Close() |
| 270 | } |
| 271 | }) |
| 272 | |
| 273 | return c.closeErr |
| 274 | } |