Delete removes an item from the cache.
(key string)
| 237 | |
| 238 | // Delete removes an item from the cache. |
| 239 | func (c *BadgerCache) Delete(key string) error { |
| 240 | err := c.db.Update(func(txn *badger.Txn) error { |
| 241 | return txn.Delete([]byte(key)) |
| 242 | }) |
| 243 | if err != nil { |
| 244 | return fmt.Errorf("badger delete operation: %w", err) |
| 245 | } |
| 246 | |
| 247 | getCacheLogger().Debug("Deleted cache item: %s", key) |
| 248 | |
| 249 | return nil |
| 250 | } |
| 251 | |
| 252 | // Clear removes all items from the cache. |
| 253 | func (c *BadgerCache) Clear() error { |