Delete 删除某个键值对应的缓存
(key string)
| 751 | |
| 752 | // Delete 删除某个键值对应的缓存 |
| 753 | func (this *FileStorage) Delete(key string) error { |
| 754 | // 是否正在退出 |
| 755 | if teaconst.IsQuiting { |
| 756 | return nil |
| 757 | } |
| 758 | |
| 759 | // 先尝试内存缓存 |
| 760 | this.runMemoryStorageSafety(func(memoryStorage *MemoryStorage) { |
| 761 | _ = memoryStorage.Delete(key) |
| 762 | }) |
| 763 | |
| 764 | hash, path, _ := this.keyPath(key) |
| 765 | err := this.list.Remove(hash) |
| 766 | if err != nil { |
| 767 | return err |
| 768 | } |
| 769 | err = this.removeCacheFile(path) |
| 770 | if err == nil || os.IsNotExist(err) { |
| 771 | return nil |
| 772 | } |
| 773 | |
| 774 | return err |
| 775 | } |
| 776 | |
| 777 | // Stat 统计 |
| 778 | func (this *FileStorage) Stat() (*Stat, error) { |
nothing calls this directly
no test coverage detected