Purge will flush the entire cache
()
| 685 | |
| 686 | // Purge will flush the entire cache |
| 687 | func (b *Persistent) Purge() { |
| 688 | b.cleanupMux.Lock() |
| 689 | defer b.cleanupMux.Unlock() |
| 690 | |
| 691 | _ = b.db.Update(func(tx *bolt.Tx) error { |
| 692 | _ = tx.DeleteBucket([]byte(RootBucket)) |
| 693 | _ = tx.DeleteBucket([]byte(RootTsBucket)) |
| 694 | _ = tx.DeleteBucket([]byte(DataTsBucket)) |
| 695 | |
| 696 | _, _ = tx.CreateBucketIfNotExists([]byte(RootBucket)) |
| 697 | _, _ = tx.CreateBucketIfNotExists([]byte(RootTsBucket)) |
| 698 | _, _ = tx.CreateBucketIfNotExists([]byte(DataTsBucket)) |
| 699 | |
| 700 | return nil |
| 701 | }) |
| 702 | |
| 703 | err := os.RemoveAll(b.dataPath) |
| 704 | if err != nil { |
| 705 | fs.Errorf(b, "issue removing data folder: %v", err) |
| 706 | } |
| 707 | err = os.MkdirAll(b.dataPath, os.ModePerm) |
| 708 | if err != nil { |
| 709 | fs.Errorf(b, "issue removing data folder: %v", err) |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | // GetChunkTs retrieves the current timestamp of this chunk |
| 714 | func (b *Persistent) GetChunkTs(path string, offset int64) (time.Time, error) { |